laravel-ide-helper icon indicating copy to clipboard operation
laravel-ide-helper copied to clipboard

[idea] Refactor to use phpstan/phpdoc-parser

Open barryvdh opened this issue 6 months ago • 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.

barryvdh avatar Feb 07 '24 13:02 barryvdh

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

barryvdh avatar Feb 07 '24 19:02 barryvdh

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..)

barryvdh avatar Feb 19 '24 12:02 barryvdh