Repository navigation
PHPStan 2.0: Internal error mixing local deps with phpstan deps #12293
Description
Activity
This bug report is missing a link to reproduction at phpstan.org/try.
It will most likely be closed after manual review.
Please show the full stack trace.
@ondrejmirtes that's one of the pain points: I have no stack trace :/
What you see when you run PHPStan with
--debug?Here it is!
Note: Using configuration file /Users/me/path/to/project/apps/website/phpstan.neon. /Users/me/path/to/project/apps/website/src/SpamDetection/NoSpamDetector.php /Users/me/path/to/project/apps/website/src/SpamDetection/SpamDetection.php /Users/me/path/to/project/apps/website/src/SpamDetection/SpamDetector.php /Users/me/path/to/project/apps/website/src/Customers/ContactMeans.php /Users/me/path/to/project/apps/website/src/Customers/Location/UnknownCustomerLocation.php /Users/me/path/to/project/apps/website/src/Customers/Location/CustomerLocationLoader.php /Users/me/path/to/project/apps/website/src/Customers/CustomerAuthenticationListener.php /Users/me/path/to/project/apps/website/src/Customers/DataPrivacy/CustomerDataAnonymizationProcessor.php /Users/me/path/to/project/apps/website/src/Customers/DataPrivacy/CustomerDataAnonymizationContextFactory.php /Users/me/path/to/project/apps/website/src/Customers/DataPrivacy/CustomerDataAnonymizationContext.php /Users/me/path/to/project/apps/website/src/Customers/DataPrivacy/Console/Command/AnonymizeActivitylessCustomersDataCommand.php Uncaught TypeError: PHPStan\PhpDocParser\Lexer\Lexer::__construct(): Argument #1 ($config) must be of type PHPStan\PhpDocParser\ParserConfig, true given, called in /Users/me/path/to/project/apps/website/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php on line 47 in phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/vendor/phpstan/phpdoc-parser/src/Lexer/Lexer.php:59 #0 /Users/me/path/to/project/apps/website/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php(47): PHPStan\PhpDocParser\Lexer\Lexer->__construct(true) #1 /Users/me/path/to/project/apps/website/vendor/phpdocumentor/reflection-docblock/src/DocBlockFactory.php(72): phpDocumentor\Reflection\DocBlock\Tags\Factory\AbstractPHPStanFactory->__construct(Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\ParamFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\VarFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\ReturnFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyReadFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\PropertyWriteFactory), Object(phpDocumentor\Reflection\DocBlock\Tags\Factory\MethodFactory)) #2 /Users/me/path/to/project/apps/website/vendor/api-platform/core/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php(51): phpDocumentor\Reflection\DocBlockFactory::createInstance() #3 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(5508): ApiPlatform\Metadata\Resource\Factory\PhpDocResourceMetadataCollectionFactory->__construct(Object(ApiPlatform\Metadata\Resource\Factory\AlternateUriResourceMetadataCollectionFactory)) #4 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(5050): ContainerM2h2wVx\App_KernelPhpstanDebugContainer::getApiPlatform_Metadata_Resource_MetadataCollectionFactory_PhpDocService(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer)) #5 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(4658): ContainerM2h2wVx\App_KernelPhpstanDebugContainer::getApiPlatform_Messenger_Metadata_Resource_MetadataCollectionFactoryService(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer)) #6 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(5359): ContainerM2h2wVx\App_KernelPhpstanDebugContainer::getApiPlatform_Doctrine_Orm_Metadata_Resource_MetadataCollectionFactoryService(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer)) #7 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_Hydra_JsonSchema_SchemaFactory_InnerService.php(31): ContainerM2h2wVx\App_KernelPhpstanDebugContainer::getApiPlatform_Metadata_Resource_MetadataCollectionFactory_CachedService(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer)) #8 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1128): ContainerM2h2wVx\getApiPlatform_Hydra_JsonSchema_SchemaFactory_InnerService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #9 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_Hydra_JsonSchema_SchemaFactoryService.php(25): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #10 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1128): ContainerM2h2wVx\getApiPlatform_Hydra_JsonSchema_SchemaFactoryService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #11 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_JsonSchema_BackwardCompatibleSchemaFactoryService.php(25): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #12 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1128): ContainerM2h2wVx\getApiPlatform_JsonSchema_BackwardCompatibleSchemaFactoryService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #13 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_JsonSchema_TypeFactoryService.php(26): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #14 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1139): ContainerM2h2wVx\getApiPlatform_JsonSchema_TypeFactoryService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #15 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_Hydra_JsonSchema_SchemaFactory_InnerService.php(25): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #16 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1139): ContainerM2h2wVx\getApiPlatform_Hydra_JsonSchema_SchemaFactory_InnerService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #17 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_Hydra_JsonSchema_SchemaFactoryService.php(25): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #18 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1139): ContainerM2h2wVx\getApiPlatform_Hydra_JsonSchema_SchemaFactoryService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #19 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_JsonSchema_BackwardCompatibleSchemaFactoryService.php(25): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #20 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1139): ContainerM2h2wVx\getApiPlatform_JsonSchema_BackwardCompatibleSchemaFactoryService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #21 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/getApiPlatform_JsonSchema_JsonSchemaGenerateCommandService.php(24): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #22 /Users/me/path/to/project/apps/website/var/cache/phpstan/ContainerM2h2wVx/App_KernelPhpstanDebugContainer.php(1139): ContainerM2h2wVx\getApiPlatform_JsonSchema_JsonSchemaGenerateCommandService::do(Object(ContainerM2h2wVx\App_KernelPhpstanDebugContainer), true) #23 /Users/me/path/to/project/apps/website/vendor/symfony/dependency-injection/Container.php(390): ContainerM2h2wVx\App_KernelPhpstanDebugContainer->load('getApiPlatform_...') #24 /Users/me/path/to/project/apps/website/vendor/symfony/dependency-injection/Argument/ServiceLocator.php(40): Symfony\Component\DependencyInjection\Container->getService('privates', 'api_platform.js...', 'getApiPlatform_...', true) #25 /Users/me/path/to/project/apps/website/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php(40): Symfony\Component\DependencyInjection\Argument\ServiceLocator->get('api_platform.js...') #26 /Users/me/path/to/project/apps/website/vendor/symfony/console/Application.php(584): Symfony\Component\Console\CommandLoader\ContainerCommandLoader->get('api:json-schema...') #27 /Users/me/path/to/project/apps/website/vendor/symfony/console/Application.php(774): Symfony\Component\Console\Application->has('api:json-schema...') #28 /Users/me/path/to/project/apps/website/vendor/symfony/framework-bundle/Console/Application.php(154): Symfony\Component\Console\Application->all(NULL) #29 /Users/me/path/to/project/apps/website/vendor/phpstan/phpstan-symfony/src/Symfony/ConsoleApplicationResolver.php(68): Symfony\Bundle\FrameworkBundle\Console\Application->all() #30 /Users/me/path/to/project/apps/website/vendor/phpstan/phpstan-symfony/src/Type/Symfony/InputInterfaceGetOptionDynamicReturnTypeExtension.php(56): PHPStan\Symfony\ConsoleApplicationResolver->findCommands(Object(PHPStan\Reflection\ClassReflection)) #31 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3714): PHPStan\Type\Symfony\InputInterfaceGetOptionDynamicReturnTypeExtension->getTypeFromMethodCall(Object(PHPStan\Reflection\ResolvedMethodReflection), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope)) #32 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1494): PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType), 'getOption', Object(PhpParser\Node\Expr\MethodCall)) #33 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1500): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}() #34 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(549): PHPStan\Analyser\MutatingScope->resolveType('$input->getOpti...', Object(PhpParser\Node\Expr\MethodCall)) #35 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(646): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall)) #36 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(549): PHPStan\Analyser\MutatingScope->resolveType('!$input->getOpt...', Object(PhpParser\Node\Expr\BooleanNot)) #37 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(763): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\BooleanNot)) #38 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(549): PHPStan\Analyser\MutatingScope->resolveType('$dryRun = !$inp...', Object(PhpParser\Node\Expr\Assign)) #39 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1754): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\Assign)) #40 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(688): PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr(Object(PhpParser\Node\Expr\Assign), Object(PHPStan\Analyser\MutatingScope)) #41 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(422): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext)) #42 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(613): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext)) #43 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(422): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext)) #44 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(754): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext)) #45 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(422): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext)) #46 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(721): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext)) #47 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(390): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext)) #48 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(162): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure)) #49 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(64): PHPStan\Analyser\FileAnalyser->analyseFile('/Users/maxim/De...', Array, Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL) #50 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(62): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array) #51 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(141): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), NULL, true, true, '/Users/maxim/De...', Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput)) #52 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(61): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/Users/maxim/De...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput)) #53 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(208): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/Users/maxim/De...', Array, Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput)) #54 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Output\ConsoleOutput)) #55 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_4afa27bf8\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Output\ConsoleOutput)) #56 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_4afa27bf8\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Output\ConsoleOutput)) #57 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_4afa27bf8\Symfony\Component\Console\Application->doRun(Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_4afa27bf8\Symfony\Component\Console\Output\ConsoleOutput)) #58 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(114): _PHPStan_4afa27bf8\Symfony\Component\Console\Application->run() #59 phar:///Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(115): _PHPStan_4afa27bf8\{closure}() #60 /Users/me/path/to/project/apps/website/vendor/phpstan/phpstan/phpstan(8): require('phar:///Users/m...') #61 /Users/me/path/to/project/apps/website/bin/phpstan(119): include('/Users/maxim/De...') #62 {main}PHPStan actually uses some code from inside your app too. You configured the phpstan-symfony extension to use the
consoleAppllicationLoaderwhich boots up your app to get valuable information for static analysis.The bug that's causing PHPStan to crash is here:
#0 /Users/me/path/to/project/apps/website/vendor/phpdocumentor/reflection-docblock/src/DocBlock/Tags/Factory/AbstractPHPStanFactory.php(47): PHPStan\PhpDocParser\Lexer\Lexer->__construct(true)Fortunately a new version of
phpdocumentor/reflection-docblockwas already released which contains this commit: phpDocumentor/ReflectionDocBlock#386So upgrade to 5.6.0 or 5.6.1 and you're good to go!
@ondrejmirtes maybe phpstan 2.x should define a composer.json conflict with the too old version of the 3rd party lib?
Reacted by Sven Reichel@staabm I wouldn't do that. Not everyone with the "bad" version will experience this problem.
Reacted by Markus StaabI'm sorry for this bug opening, I was pretty sure to have already run
composer update phpdocumentor/reflection-docblock!At least it document how to fix it now 😄 .
Thank you for your precious time!This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
- locked as resolved and limited conversation to collaborators
on Jan 20, 2025
Bug report
I wanted to upgrade to phpstan 2 but I ended up with errors like this:
Some of them was solvable by upgrading local dependencies. Some others are blocking because I cannot upgrade local dependencies. By "local" I mean the
vendor/composer.jsonof my project, because I'm installing phpstan in another folder. (I also tried to install phpstan directly on the project, still didn't work)Code snippet that reproduces the problem
No response
Expected output
The expected output is no internal error. Or something more clear about what's wrong. (isn't super-weird that phpstan is loading the local dependencies instead of its own?)
Did PHPStan help you today? Did it make you happy in any way?
I'm not sure phpstan makes me happy, most part of the time it makes my life harder 😄 . But I'm really glad it avoids so much errors in production. 🫶 Thanks