phpstan / phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
https://phpstan.org/
MIT License
12.81k stars 867 forks source link

Internal Error #11520

Closed johntheteam closed 3 weeks ago

johntheteam commented 3 weeks ago
### Bug report

When working on a Laravel package using blade template, got internal error
 -- ------------------------------------------------------------------------------------------- 
     Error                                                                                      
 -- ------------------------------------------------------------------------------------------- 
     Internal error:  while analysing file                                                      
     /Users/johntest/test/api/src/packages/uqlibrary/fez_core/src/FezCoreRecordsController.php  
     Run PHPStan with -v option and post the stack trace to:                                    
     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml                     
 -- ------------------------------------------------------------------------------------------- 
 [ERROR] Found 1 error                                                          
⚠️  Result is incomplete because of severe errors. ⚠️
   Fix these errors first and then re-run PHPStan
   to get all reported errors.

Since you ask to post the stack trace here, here you are: :)

johntest@libMQH api % src/vendor/bin/phpstan  --no-interaction --no-progress --memory-limit=-1 --configuration=src/phpstan.neon analyze --debug -vvv src/packages/uqlibrary/fez_core/src/FezCoreRecordsController.php

 ! [NOTE] The Xdebug PHP extension is active, but "--xdebug" is not used.                                               
 !        The process was restarted and it will not halt at breakpoints.                                                
 !        Use "--xdebug" if you want to halt at breakpoints.                                                            

Result cache not used because of debug mode.
/Users/johntest/test/api/src/packages/uqlibrary/fez_core/src/FezCoreRecordsController.php
Uncaught TomasVotruba\Bladestan\Exception\ShouldNotHappenException:  in /Users/johntest/test/api/src/vendor/tomasvotruba/bladestan/src/PhpParser/NodeVisitor/ViewFunctionArgumentsNodeVisitor.php:77
#0 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(113): TomasVotruba\Bladestan\PhpParser\NodeVisitor\ViewFunctionArgumentsNodeVisitor->enterNode(Object(PhpParser\Node\Expr\MethodCall))
#1 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Expr\MethodCall))
#2 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Expr\MethodCall))
#3 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(133): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Expr\MethodCall))
#4 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Return_))
#5 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#6 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\If_))
#7 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#8 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\TryCatch))
#9 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#10 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\If_))
#11 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#12 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\ClassMethod))
#13 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#14 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Class_))
#15 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(105): PhpParser\NodeTraverser->traverseArray(Array)
#16 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(196): PhpParser\NodeTraverser->traverseNode(Object(PhpParser\Node\Stmt\Namespace_))
#17 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php(85): PhpParser\NodeTraverser->traverseArray(Array)
#18 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Parser/RichParser.php(107): PhpParser\NodeTraverser->traverse(Array)
#19 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Parser/RichParser.php(79): PHPStan\Parser\RichParser->parseString('<?php\n\nnamespac...')
#20 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Parser/PathRoutingParser.php(77): PHPStan\Parser\RichParser->parseFile('/Users/johntest...')
#21 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/FileNodesFetcher.php(31): PHPStan\Parser\PathRoutingParser->parseFile('/Users/johntest...')
#22 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/NewOptimizedDirectorySourceLocator.php(57): PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher->fetchNodes('/Users/johntest...')
#23 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php(26): PHPStan\Reflection\BetterReflection\SourceLocator\NewOptimizedDirectorySourceLocator->locateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
#24 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/SourceLocator/RewriteClassAliasSourceLocator.php(34): PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
#25 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/AggregateSourceLocator.php(26): PHPStan\Reflection\BetterReflection\SourceLocator\RewriteClassAliasSourceLocator->locateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
#26 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocator.php(33): PHPStan\BetterReflection\SourceLocator\Type\AggregateSourceLocator->locateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
#27 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/ondrejmirtes/better-reflection/src/Reflector/DefaultReflector.php(32): PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->locateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector), Object(PHPStan\BetterReflection\Identifier\Identifier))
#28 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/Reflector/MemoizingReflector.php(45): PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass('Uqlibrary\\FezCo...')
#29 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/BetterReflection/BetterReflectionProvider.php(163): PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflectClass('Uqlibrary\\FezCo...')
#30 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ReflectionProvider/MemoizingReflectionProvider.php(35): PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasClass('Uqlibrary\\FezCo...')
#31 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(1181): PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasClass('Uqlibrary\\FezCo...')
#32 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Type/StaticType.php(71): PHPStan\Type\ObjectType->getAncestorWithClassName('Uqlibrary\\FezCo...')
#33 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(2104): PHPStan\Type\StaticType->getAncestorWithClassName('Uqlibrary\\FezCo...')
#34 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassPropertiesNode.php(310): PHPStan\Analyser\MutatingScope->resolveTypeByName(Object(PhpParser\Node\Name\FullyQualified))
#35 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassPropertiesNode.php(170): PHPStan\Node\ClassPropertiesNode->getMethodsCalledFromConstructor(Object(PHPStan\Reflection\ClassReflection), Array, Array, Array, Array)
#36 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Rules/Properties/MissingReadOnlyPropertyAssignRule.php(33): PHPStan\Node\ClassPropertiesNode->getUninitializedProperties(Object(PHPStan\Analyser\MutatingScope), Array)
#37 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(120): PHPStan\Rules\Properties\MissingReadOnlyPropertyAssignRule->processNode(Object(PHPStan\Node\ClassPropertiesNode), Object(PHPStan\Analyser\MutatingScope))
#38 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(784): PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PHPStan\Node\ClassPropertiesNode), Object(PHPStan\Analyser\MutatingScope))
#39 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(458): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#40 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(753): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#41 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(423): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\StatementContext))
#42 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(179): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
#43 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(79): PHPStan\Analyser\FileAnalyser->analyseFile('/Users/johntest...', Array, Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)
#44 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(74): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), Object(Closure), true, Array)
#45 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(159): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), Object(Closure), true, true, '/Users/johntest...', Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput))
#46 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(79): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/Users/johntest...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput))
#47 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(221): PHPStan\Command\AnalyseApplication->analyse(Array, true, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/Users/johntest...', Array, Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput))
#48 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_2229debcd\Symfony\Component\Console\Output\ConsoleOutput))
#49 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870): _PHPStan_2229debcd\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_2229debcd\Symfony\Component\Console\Output\ConsoleOutput))
#50 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261): _PHPStan_2229debcd\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_2229debcd\Symfony\Component\Console\Output\ConsoleOutput))
#51 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_2229debcd\Symfony\Component\Console\Application->doRun(Object(_PHPStan_2229debcd\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_2229debcd\Symfony\Component\Console\Output\ConsoleOutput))
#52 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_2229debcd\Symfony\Component\Console\Application->run()
#53 phar:///Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_2229debcd\{closure}()
#54 /Users/johntest/test/api/src/vendor/phpstan/phpstan/phpstan(8): require('phar:///Users/u...')
#55 /Users/johntest/test/api/src/vendor/bin/phpstan(119): include('/Users/johntest...')
#56 {main}
Elapsed time: 14 seconds

### Code snippet that reproduces the problem

_No response_

### Expected output

Expect to see the error message that's helpful. 

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

_No response_
mergeable[bot] commented 3 weeks ago

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

It will most likely be closed after manual review.

ondrejmirtes commented 3 weeks ago

See the stack trace:

Uncaught TomasVotruba\Bladestan\Exception\ShouldNotHappenException: in /Users/johntest/test/api/src/vendor/tomasvotruba/bladestan/src/PhpParser/NodeVisitor/ViewFunctionArgumentsNodeVisitor.php:77

This bug is in Bladestan, open a bug report there.