Problem
typhoon/reflection currently requires phpstan/phpdoc-parser ^1.21 in both 0.4.4 and 0.5.x-dev.
Projects that upgrade their tooling to PHPStan 2 / Rector 2 can end up with phpstan/phpdoc-parser v2 loaded in the same PHP process. In that case Typhoon Reflection still instantiates the v1 API:
private readonly Lexer $lexer = new Lexer(),
but phpdoc-parser v2 requires ParserConfig in PHPStan\PhpDocParser\Lexer\Lexer::__construct().
This causes runtime failures such as:
ArgumentCountError: Too few arguments to function PHPStan\PhpDocParser\Lexer\Lexer::__construct(), 0 passed in vendor/typhoon/reflection/Internal/PhpDoc/PhpDocParser.php on line 30 and exactly 1 expected
In our case this happened after upgrading bitrix24/b24phpsdk to PHPStan 2 and Rector 2. Rector 2 registers a Composer autoload file and, under PHPUnit 12, can preload its bundled phpdoc-parser v2 before project code that uses Typhoon Reflection.
Reproduction context
Proposed solution
Add support for phpstan/phpdoc-parser ^2, or provide a compatibility layer that constructs parser services differently depending on the installed parser version.
At minimum, it would help to know whether v2 support is planned for 0.5.x.
Related
Problem
typhoon/reflectioncurrently requiresphpstan/phpdoc-parser ^1.21in both0.4.4and0.5.x-dev.Projects that upgrade their tooling to PHPStan 2 / Rector 2 can end up with
phpstan/phpdoc-parserv2 loaded in the same PHP process. In that case Typhoon Reflection still instantiates the v1 API:but phpdoc-parser v2 requires
ParserConfiginPHPStan\PhpDocParser\Lexer\Lexer::__construct().This causes runtime failures such as:
In our case this happened after upgrading
bitrix24/b24phpsdkto PHPStan 2 and Rector 2. Rector 2 registers a Composer autoload file and, under PHPUnit 12, can preload its bundled phpdoc-parser v2 before project code that uses Typhoon Reflection.Reproduction context
typhoon/reflection: 0.4.4phpstan/phpdoc-parser: v1 required bytyphoon/reflectionphpstan/phpstan ^2,rector/rector ^2Proposed solution
Add support for
phpstan/phpdoc-parser ^2, or provide a compatibility layer that constructs parser services differently depending on the installed parser version.At minimum, it would help to know whether v2 support is planned for
0.5.x.Related