barryvdh/laravel-ide-helper

[idea] Refactor to use phpstan/phpdoc-parser

barryvdh opened this issue · 2 comments

Just throwing this as a reminder/placeholder.

I came across https://github.com/phpstan/phpdoc-parser which is a zero-requirements package to parse and modify phpdocs.
I've forked https://github.com/barryvdh/ReflectionDocBlock in the past because the original didn't support modifying phpdocs, but it's clearly not so up-to-date.

It would be interesting to see if we can migrate to use that library instead.

I think it's not as easy, because that parser doesn't support the context. So you would need something like https://github.com/phpDocumentor/TypeResolver or https://github.com/phpstan/phpstan-src/blob/1.6.x/src/PhpDoc/TypeNodeResolver.php#L160 to resolve the type for us.

Edit: we're already using phpdocumentor/type-resolver so that's not an issue per se

Also something interesting: https://packagist.org/packages/symfony/property-info
For phpdocs we don't really want processing, just want to build it. But for types, we want to use multiple sources (we often already use both reflection, phpdocs and more..)