phpstan / phpstan-doctrine

Doctrine extensions for PHPStan
MIT License
595 stars 97 forks source link

Internal error #602

Closed lukaszkowol closed 2 months ago

lukaszkowol commented 3 months ago

Bug report

Internal error: Internal error: get_class(): Argument phpstan/phpstan#1 ($object) must be of type object, array given while analysing file
/app/src/Infrastructure/Doctrine/MT3/Repository/TrainableConfigurationRepository.php

 Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:                                                             
 ## /app/vendor/doctrine/orm/src/Query/Expr/Base.php(72)                                                                                                               
 #0 /app/vendor/doctrine/orm/src/Query/Expr/Base.php(55): Doctrine\ORM\Query\Expr\Base->add(Array)                                                                     
 phpstan/phpstan#1 /app/vendor/doctrine/orm/src/Query/Expr/Base.php(43): Doctrine\ORM\Query\Expr\Base->addMultiple(Array)                                                             
 phpstan/phpstan#2 /app/vendor/doctrine/orm/src/Query/Expr.php(66): Doctrine\ORM\Query\Expr\Base->__construct(Array)                                                                  
 phpstan/phpstan#3 /app/vendor/phpstan/phpstan-doctrine/src/Type/Doctrine/QueryBuilder/Expr/ExpressionBuilderDynamicReturnTypeExtension.php(82): Doctrine\ORM\Query\Expr->orX(Array)  
 phpstan/phpstan#4 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3630):                                                                              
 PHPStan\Type\Doctrine\QueryBuilder\Expr\ExpressionBuilderDynamicReturnTypeExtension->getTypeFromMethodCall(Object(PHPStan\Reflection\ResolvedMethodReflection),       
 Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                                                                                       
 phpstan/phpstan#5 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1420):                                                                              
 PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\ObjectType), 'orX', Object(PhpParser\Node\Expr\MethodCall))                                  
 phpstan/phpstan#6 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1426): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()                 
 phpstan/phpstan#7 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(589): PHPStan\Analyser\MutatingScope->resolveType('$queryBuilder->...',             
 Object(PhpParser\Node\Expr\MethodCall))                                                                                                                               
 phpstan/phpstan#8 /app/vendor/phpstan/phpstan-doctrine/src/Rules/Doctrine/ORM/RepositoryMethodCallRule.php(40):                                                                      
 PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall))                                                                                       
 phpstan/phpstan#9 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(107):                                                                                
 PHPStan\Rules\Doctrine\ORM\RepositoryMethodCallRule->processNode(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                      
 phpstan/phpstan#10 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Node/ClassStatementsGatherer.php(108):                                                                        
 PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                             
 phpstan/phpstan#11 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(586):                                                                          
 PHPStan\Node\ClassStatementsGatherer->__invoke(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                                        
 phpstan/phpstan#12 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2758):                                                                         
 PHPStan\Analyser\NodeScopeResolver::PHPStan\Analyser\{closure}(Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))                        
 phpstan/phpstan#13 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1642):                                                                         
 PHPStan\Analyser\NodeScopeResolver->callNodeCallbackWithExpression(Object(Closure), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope),   
 Object(PHPStan\Analyser\ExpressionContext))                                                                                                                           
 phpstan/phpstan#14 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(646):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Stmt\Expression), Object(PhpParser\Node\Expr\MethodCall),                                   
 Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))                                                                  
 phpstan/phpstan#15 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(420):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure),                  
 Object(PHPStan\Analyser\StatementContext))                                                                                                                            
 phpstan/phpstan#16 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(585):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure),         
 Object(PHPStan\Analyser\StatementContext))                                                                                                                            
 phpstan/phpstan#17 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(420):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope),                                  
 Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))                                                                              
 phpstan/phpstan#18 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(687):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope),                               
 Object(PHPStan\Node\ClassStatementsGatherer), Object(PHPStan\Analyser\StatementContext))                                                                              
 phpstan/phpstan#19 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(420):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure),                      
 Object(PHPStan\Analyser\StatementContext))                                                                                                                            
 phpstan/phpstan#20 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(659):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure),          
 Object(PHPStan\Analyser\StatementContext))                                                                                                                            
 phpstan/phpstan#21 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(389):                                                                          
 PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure),                  
 Object(PHPStan\Analyser\StatementContext))                                                                                                                            
 phpstan/phpstan#22 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(166): PHPStan\Analyser\NodeScopeResolver->processNodes(Array,                       
 Object(PHPStan\Analyser\MutatingScope), Object(Closure))                                                                                                              
 phpstan/phpstan#23 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(132): PHPStan\Analyser\FileAnalyser->analyseFile('/app/src/Infras...', Array,       
 Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)                                                                                        
 phpstan/phpstan#24 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                               
 PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}(Array)                                                                                                       
 phpstan/phpstan#25 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117): _PHPStan_7961f7ae1\Evenement\EventEmitter->emit('data', Array)     
 phpstan/phpstan#26 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                               
 _PHPStan_7961f7ae1\Clue\React\NDJson\Decoder->handleData(Array)                                                                                                       
 phpstan/phpstan#27 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_7961f7ae1\Evenement\EventEmitter->emit('data', Array)              
 phpstan/phpstan#28 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                               
 _PHPStan_7961f7ae1\React\Stream\Util::_PHPStan_7961f7ae1\React\Stream\{closure}('{"action":"anal...')                                                                 
 phpstan/phpstan#29 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_7961f7ae1\Evenement\EventEmitter->emit('data',    
 Array)                                                                                                                                                                
 phpstan/phpstan#30 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):                                                            
 _PHPStan_7961f7ae1\React\Stream\DuplexResourceStream->handleData(Resource id phpstan/phpstan#5661)                                                                                   
 phpstan/phpstan#31 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):                                                            
 _PHPStan_7961f7ae1\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)                                                                                      
 phpstan/phpstan#32 phar:///app/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(98): _PHPStan_7961f7ae1\React\EventLoop\StreamSelectLoop->run()                     
 phpstan/phpstan#33 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):                                                                  
 PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Input\ArgvInput),                                                          
 Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Output\ConsoleOutput))                                                                                            
 phpstan/phpstan#34 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(870):                                                                      
 _PHPStan_7961f7ae1\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Input\ArgvInput),                               
 Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Output\ConsoleOutput))                                                                                            
 phpstan/phpstan#35 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):                                                                      
 _PHPStan_7961f7ae1\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\WorkerCommand),                                                         
 Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Output\ConsoleOutput))                      
 phpstan/phpstan#36 phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):                                                                      
 _PHPStan_7961f7ae1\Symfony\Component\Console\Application->doRun(Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Input\ArgvInput),                                 
 Object(_PHPStan_7961f7ae1\Symfony\Component\Console\Output\ConsoleOutput))                                                                                            
 phpstan/phpstan#37 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_7961f7ae1\Symfony\Component\Console\Application->run()                                 
 phpstan/phpstan#38 phar:///app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_7961f7ae1\{closure}()                                                                  
 phpstan/phpstan#39 /app/vendor/phpstan/phpstan/phpstan(8): require('phar:///app/ven...')                                                                                             
 phpstan/phpstan#40 /app/vendor/bin/phpstan(119): include('/app/vendor/php...')                                                                                                       
 phpstan/phpstan#41 {main}                                                                                                                                                            
 Child process error (exit code 1):                                                    

Code snippet that reproduces the problem

    $queryBuilder->andWhere($queryBuilder->expr()->orX(...$objectConditions));

Expected output

No error

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

No response

mergeable[bot] commented 3 months 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 2 months ago

Hi, I'm unable to reproduce it, can you give me a hand with that? Thanks: https://github.com/phpstan/phpstan-doctrine/commit/6632f382180746fa4b317b4dae30e242f2e990f9

github-actions[bot] commented 1 month ago

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.