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: ProphesizeDynamicReturnTypeExtension #10582

Closed
JustusNBB opened this issue Feb 14, 2024 · 4 comments
Closed

Internal error: ProphesizeDynamicReturnTypeExtension #10582

JustusNBB opened this issue Feb 14, 2024 · 4 comments

Comments

@JustusNBB
Copy link

Bug report

Hi!
I'm upgrading a Shopware project from PHP8.1 to 8.2, seems we had not run a full composer update for a while...

I've managed to silence the phpstan issues, but this one is asking me to create a Bugreport:

--------------------------------------------------------- 
     Error                                                                                                                                             
 -- -------------------------------------------------------------------------------------------------------------------------------------------------- 
     Internal error: Internal error: Internal error. while analysing file                                                                              
     /app/tests/Helper/DtoFactory.php                                                                                                                  
                                                                                                                                                       
     Post the following stack trace to                                                                                                                 
     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:                                                                           
     ##                                                                                                                                                
     /app/vendor/jangregor/phpstan-prophecy/src/Type/Prophet/ProphesizeDynamicReturnTypeExtension.php(70)                                              
     #0                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3610):                                                             
     JanGregor\Prophecy\Type\Prophet\ProphesizeDynamicReturnTypeExtension->getTypeFromMethodCall(Object(PHPStan\Reflection\ResolvedMethodReflection),  
     Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                                                                   
     #1                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1416):                                                             
     PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType),                                                             
     'prophesize', Object(PhpParser\Node\Expr\MethodCall))                                                                                             
     #2                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1422):                                                             
     PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()                                                                                      
     #3                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(587):                                                              
     PHPStan\Analyser\MutatingScope->resolveType('$prophet->proph...',                                                                                 
     Object(PhpParser\Node\Expr\MethodCall))                                                                                                           
     #4                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1416):                                                             
     PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall))                                                                   
     #5                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1422):                                                             
     PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()                                                                                      
     #6                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(587):                                                              
     PHPStan\Analyser\MutatingScope->resolveType('$prophet->proph...',                                                                                 
     Object(PhpParser\Node\Expr\MethodCall))                                                                                                           
     #7                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Rules/FunctionCallParametersCheck.php(114):                                                   
     PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall))                                                                   
     #8                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Rules/Classes/InstantiationRule.php(131):                                                     
     PHPStan\Rules\FunctionCallParametersCheck->check(Object(PHPStan\Reflection\FunctionVariantWithPhpDocs),                                           
     Object(PHPStan\Analyser\MutatingScope), false, Object(PhpParser\Node\Expr\New_),                                                                  
     Array)                                                                                                                                            
     #9                                                                                                                                                
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Rules/Classes/InstantiationRule.php(57):                                                      
     PHPStan\Rules\Classes\InstantiationRule->checkClassName('Shopware\\Core\\F...',                                                                   
     true, Object(PhpParser\Node\Expr\New_), Object(PHPStan\Analyser\MutatingScope))                                                                   
     #10                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(107):                                                               
     PHPStan\Rules\Classes\InstantiationRule->processNode(Object(PhpParser\Node\Expr\New_),                                                            
     Object(PHPStan\Analyser\MutatingScope))                                                                                                           
     #11                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(108):                                                        
     PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PhpParser\Node\Expr\New_),                                                       
     Object(PHPStan\Analyser\MutatingScope))                                                                                                           
     #12                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(575):                                                          
     PHPStan\Node\ClassStatementsGatherer->__invoke(Object(PhpParser\Node\Expr\New_),                                                                  
     Object(PHPStan\Analyser\MutatingScope))                                                                                                           
     #13                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2716):                                                         
     PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}(Object(PhpParser\Node\Expr\New_),                                                  
     Object(PHPStan\Analyser\MutatingScope))                                                                                                           
     #14                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1631):                                                         
     PHPStan\Analyser\NodeScopeResolver->callNodeCallbackWithExpression(Object(Closure),                                                               
     Object(PhpParser\Node\Expr\New_), Object(PHPStan\Analyser\MutatingScope),                                                                         
     Object(PHPStan\Analyser\ExpressionContext))                                                                                                       
     #15                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(613):                                                          
     PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Stmt\Return_),                                                          
     Object(PhpParser\Node\Expr\New_), Object(PHPStan\Analyser\MutatingScope),                                                                         
     Object(Closure), Object(PHPStan\Analyser\ExpressionContext))                                                                                      
     #16                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(409):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Return_),                                                          
     Object(PHPStan\Analyser\MutatingScope), Object(Closure),                                                                                          
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #17                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(574):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod),                                                     
     Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure),                                                                                   
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #18                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(409):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod),                                                      
     Object(PHPStan\Analyser\MutatingScope),                                                                                                           
     Object(PHPStan\Node\ClassStatementsGatherer),                                                                                                     
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #19                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(676):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_),                                                          
     Array, Object(PHPStan\Analyser\MutatingScope),                                                                                                    
     Object(PHPStan\Node\ClassStatementsGatherer),                                                                                                     
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #20                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(409):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_),                                                           
     Object(PHPStan\Analyser\MutatingScope), Object(Closure),                                                                                          
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #21                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(648):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_),                                                      
     Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure),                                                                                   
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #22                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(378):                                                          
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_),                                                       
     Object(PHPStan\Analyser\MutatingScope), Object(Closure),                                                                                          
     Object(PHPStan\Analyser\StatementContext))                                                                                                        
     #23                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(166):                                                               
     PHPStan\Analyser\NodeScopeResolver->processNodes(Array,                                                                                           
     Object(PHPStan\Analyser\MutatingScope), Object(Closure))                                                                                          
     #24                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(132):                                                               
     PHPStan\Analyser\FileAnalyser->analyseFile('/app/tests/Help...', Array,                                                                           
     Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)                                                                    
     #25                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                               
     PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}(Array)                                                                                   
     #26                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117):                                                    
     _PHPStan_156ee64ba\Evenement\EventEmitter->emit('data', Array)                                                                                    
     #27                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                               
     _PHPStan_156ee64ba\Clue\React\NDJson\Decoder->handleData(Array)                                                                                   
     #28                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62):                                                             
     _PHPStan_156ee64ba\Evenement\EventEmitter->emit('data', Array)                                                                                    
     #29                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                               
     _PHPStan_156ee64ba\React\Stream\Util::_PHPStan_156ee64ba\React\Stream\{closure}('{"action":"anal...')                                             
     #30                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154):                                            
     _PHPStan_156ee64ba\Evenement\EventEmitter->emit('data', Array)                                                                                    
     #31                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):                                            
     _PHPStan_156ee64ba\React\Stream\DuplexResourceStream->handleData(Resource id                                                                      
     #8096)                                                                                                                                            
     #32                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):                                            
     _PHPStan_156ee64ba\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)                                                                  
     #33                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(98):                                                                
     _PHPStan_156ee64ba\React\EventLoop\StreamSelectLoop->run()                                                                                        
     #34                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):                                                  
     PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_156ee64ba\Symfony\Component\Console\Input\ArgvInput),                                      
     Object(_PHPStan_156ee64ba\Symfony\Component\Console\Output\ConsoleOutput))                                                                        
     #35                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870):                                                      
     _PHPStan_156ee64ba\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_156ee64ba\Symfony\Component\Console\Input\ArgvInput),           
     Object(_PHPStan_156ee64ba\Symfony\Component\Console\Output\ConsoleOutput))                                                                        
     #36                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):                                                      
     _PHPStan_156ee64ba\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\WorkerCommand),                                     
     Object(_PHPStan_156ee64ba\Symfony\Component\Console\Input\ArgvInput),                                                                             
     Object(_PHPStan_156ee64ba\Symfony\Component\Console\Output\ConsoleOutput))                                                                        
     #37                                                                                                                                               
     phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):                                                      
     _PHPStan_156ee64ba\Symfony\Component\Console\Application->doRun(Object(_PHPStan_156ee64ba\Symfony\Component\Console\Input\ArgvInput),             
     Object(_PHPStan_156ee64ba\Symfony\Component\Console\Output\ConsoleOutput))                                                                        
     #38 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124):                                                                             
     _PHPStan_156ee64ba\Symfony\Component\Console\Application->run()                                                                                   
     #39 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125):                                                                             
     _PHPStan_156ee64ba\{closure}()                                                                                                                    
     #40 /app/vendor/phpstan/phpstan/phpstan(8): require('phar:///app/ven...')                                                                         
     #41 /app/vendor/bin/phpstan(117): include('/app/vendor/php...')                                                                                   
     #42 {main}                                                                                                                                        
     Child process error (exit code 1):             

Code snippet that reproduces the problem

No response

Expected output

No error?!

Sorry, I'll need more instruction and time to give you a reproduction, please give me some hints and I'll try.

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

I'm glad to see phpstan now analyses types even more closely now, but having to sprinkle phpstan ignore in a bunch of places is not making me happy.

Copy link

mergeable bot commented Feb 14, 2024

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

Not a bug in PHPStan, but in jangregor/phpstan-prophecy. Please open a bug report there.

@danepowell
Copy link

I think this is a dupe of #10272 , which includes a reproducible example. At any rate, the root cause seems to be an undocumented breaking change in phpspec/prophecy which may be resolved in phpstan-prophecy: Jan0707/phpstan-prophecy#315

Copy link

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 Mar 18, 2024
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

3 participants