Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal error: Call to undefined method PhpParser\PrettyPrinter\Standard::pPHPStan_Node_AlwaysRememberedExpr() while analysing file <file> #10086

Closed
rx80 opened this issue Nov 2, 2023 · 6 comments

Comments

@rx80
Copy link

rx80 commented Nov 2, 2023

Bug report

Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml: 
## phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(503)
#0 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php(579): PhpParser\PrettyPrinterAbstract->p()
#1 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(503): PhpParser\PrettyPrinter\Standard->pExpr_Match()
#2 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php(587): PhpParser\PrettyPrinterAbstract->p()
#3 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(503): PhpParser\PrettyPrinter\Standard->pExpr_ArrowFunction()
#4 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php(927): PhpParser\PrettyPrinterAbstract->p()
#5 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinter/Standard.php(484): PhpParser\PrettyPrinter\Standard->pCallLhs()
#6 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(503): PhpParser\PrettyPrinter\Standard->pExpr_FuncCall()
#7 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(293): PhpParser\PrettyPrinterAbstract->p()
#8 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/PrettyPrinterAbstract.php(207): PhpParser\PrettyPrinterAbstract->pStmts()
#9 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflection/Exception/InvalidConstantNode.php(15): PhpParser\PrettyPrinterAbstract->prettyPrint()
#10 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Util/ConstantNodeChecker.php(18): PHPStan\BetterReflection\Reflection\Exception\InvalidConstantNode::create()
#11 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/CachingVisitor.php(69): PHPStan\BetterReflection\Util\ConstantNodeChecker::assertValidDefineFunctionCall()
#12 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): PHPStan\Reflection\BetterReflection\SourceLocator\CachingVisitor->enterNode()
#13 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#14 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode()
#15 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode()
#16 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray()
#17 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/FileNodesFetcher.php(36): PhpParser\NodeTraverser->traverse()
#18 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/NewOptimizedDirectorySourceLocator.php(88): PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher->fetchNodes()
#19 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php(26): PHPStan\Reflection\BetterReflection\SourceLocator\NewOptimizedDirectorySourceLocator->locateIdentifier()
#20 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/RewriteClassAliasSourceLocator.php(28): PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier()
#21 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php(26): PHPStan\Reflection\BetterReflection\SourceLocator\RewriteClassAliasSourceLocator->locateIdentifier()
#22 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocator.php(33): PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier()
#23 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/DefaultReflector.php(84): PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier()
#24 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingReflector.php(61): PHPStan\BetterReflection\Reflector\DefaultReflector->reflectConstant()
#25 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(319): PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectConstant()
#26 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(341): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->PHPStan\Reflection\BetterReflection\{closure}()
#27 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(317): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->resolveName()
#28 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(299): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->resolveConstantName()
#29 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(75): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasConstant()
#30 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/ConstantResolver.php(49): PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasConstant()
#31 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1320): PHPStan\Analyser\ConstantResolver->resolveConstant()
#32 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(566): PHPStan\Analyser\MutatingScope->resolveType()
#33 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/TypeSpecifier.php(875): PHPStan\Analyser\MutatingScope->getType()
#34 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/TypeSpecifier.php(862): PHPStan\Analyser\TypeSpecifier->createForExpr()
#35 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Type/Php/DefineConstantTypeSpecifyingExtension.php(37): PHPStan\Analyser\TypeSpecifier->create()
#36 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/TypeSpecifier.php(319): PHPStan\Type\Php\DefineConstantTypeSpecifyingExtension->specifyTypes()
#37 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(605): PHPStan\Analyser\TypeSpecifier->specifyTypesInCondition()
#38 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(357): PHPStan\Analyser\NodeScopeResolver->processStmtNode()
#39 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(166): PHPStan\Analyser\NodeScopeResolver->processNodes()
#40 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(132): PHPStan\Analyser\FileAnalyser->analyseFile()
#41 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}()
#42 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117): _PHPStan_d5c599c96\Evenement\EventEmitter->emit()
#43 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_d5c599c96\Clue\React\NDJson\Decoder->handleData()
#44 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_d5c599c96\Evenement\EventEmitter->emit()
#45 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97): _PHPStan_d5c599c96\React\Stream\Util::_PHPStan_d5c599c96\React\Stream\{closure}()
#46 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_d5c599c96\Evenement\EventEmitter->emit()
#47 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201): _PHPStan_d5c599c96\React\Stream\DuplexResourceStream->handleData()
#48 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173): _PHPStan_d5c599c96\React\EventLoop\StreamSelectLoop->waitForStreamActivity()
#49 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(98): _PHPStan_d5c599c96\React\EventLoop\StreamSelectLoop->run()
#50 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\WorkerCommand->execute()
#51 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_d5c599c96\Symfony\Component\Console\Command\Command->run()
#52 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_d5c599c96\Symfony\Component\Console\Application->doRunCommand()
#53 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_d5c599c96\Symfony\Component\Console\Application->doRun()
#54 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_d5c599c96\Symfony\Component\Console\Application->run()
#55 phar:///<project_path>/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_d5c599c96\{closure}()
#56 /<project_path>/vendor/phpstan/phpstan/phpstan(8): require('...')
#57 /<project_path>/vendor/bin/phpstan(119): include('...')
#58 {main}

Code snippet that reproduces the problem

https://phpstan.org/r/8e8d2879-3325-42a5-bab2-fb34d845472b

Expected output

Should correctly analyse file, but doesn't.

Did PHPStan help you today? Did it make you happy in any way?

No response

Copy link

mergeable bot commented Nov 2, 2023

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@ondrejmirtes
Copy link
Member

Please show a piece of code for which this happens.

@rx80
Copy link
Author

rx80 commented Nov 3, 2023

@ondrejmirtes I have 2 files within my project for which this happens, however if i analyse the same file outside the project, it works correctly. I tried clearing the cache, not sure what else i can do to isolate the example.
I will try more this weekend.

@rx80
Copy link
Author

rx80 commented Nov 3, 2023

Please show a piece of code for which this happens.

Added a reproducer in issue, also here: https://phpstan.org/r/8e8d2879-3325-42a5-bab2-fb34d845472b

@ondrejmirtes
Copy link
Member

Fixed in BetterReflection by using the same Printer everywhere: ondrejmirtes/BetterReflection@bab47ea

Updated in PHPStan: phpstan/phpstan-src#2713

Copy link

github-actions bot commented Dec 6, 2023

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants