Skip to content

Internal Error: Method count() was not found in reflection #13187

@dereuromark

Description

@dereuromark

Bug report

 -- ---------------------------------------------------------------------------------------------------------------------------- 
     Error                                                                                                                       
 -- ---------------------------------------------------------------------------------------------------------------------------- 
     Internal error: Method count() was not found in reflection of class Cake\Database\StatementInterface. while analysing file  
     /var/www/html/src/Controller/ReportsController.php                                                                          

-v doesnt say too much more

With hundreds and thousands of classes this is super hard to debug.
Any way to make this a normal error amongst the others?

Result cache was not saved because of error in dependencies.
 -- -------------------------------------------------------------------------------------------------------------------------------- 
     Error                                                                                                                           
 -- -------------------------------------------------------------------------------------------------------------------------------- 
     Internal error: Method count() was not found in reflection of class Cake\Database\StatementInterface. while analysing file      
     /var/www/html/src/Controller/ReportsController.php                                                                              
     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:                       
     ## phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Reflection/ClassReflection.php(479)                             
     #0 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(637):                                       
     PHPStan\Reflection\ClassReflection->getMethod()                                                                                 
     #1 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(614):                                       
     PHPStan\Type\ObjectType->getUnresolvedMethodPrototype()                                                                         
     #2 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(717): PHPStan\Type\ObjectType->getMethod()  
     #3 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/RecursionGuard.php(23):                                    
     PHPStan\Type\ObjectType->PHPStan\Type\{closure}()                                                                               
     #4 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/ObjectType.php(717): PHPStan\Type\RecursionGuard::run()    
     #5 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Type/Php/CountFunctionReturnTypeExtension.php(34):              
     PHPStan\Type\ObjectType->getArraySize()                                                                                         
     #6 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1708):                               
     PHPStan\Type\Php\CountFunctionReturnTypeExtension->getTypeFromFunctionCall()                                                    
     #7 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(594):                                
     PHPStan\Analyser\MutatingScope->resolveType()                                                                                   
     #8 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(808):                                
     PHPStan\Analyser\MutatingScope->getType()                                                                                       
     #9 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(594):                                
     PHPStan\Analyser\MutatingScope->resolveType()                                                                                   
     #10 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1937):                          
     PHPStan\Analyser\MutatingScope->getType()                                                                                       
     #11 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(802):                           
     PHPStan\Analyser\NodeScopeResolver->findEarlyTerminatingExpr()                                                                  
     #12 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(511):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode()                                                                           
     #13 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(939):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes()                                                                          
     #14 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(511):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode()                                                                           
     #15 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(704):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes()                                                                          
     #16 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(511):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode()                                                                           
     #17 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(884):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes()                                                                          
     #18 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(511):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode()                                                                           
     #19 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(835):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes()                                                                          
     #20 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(459):                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode()                                                                           
     #21 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(203):                                
     PHPStan\Analyser\NodeScopeResolver->processNodes()                                                                              
     #22 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(149):                                
     PHPStan\Analyser\FileAnalyser->analyseFile()                                                                                    
     #23 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):         
     PHPStan\Command\WorkerCommand::PHPStan\Command\{closure}()                                                                      
     #24 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(117):                     
     _PHPStan_42eac28f8\Evenement\EventEmitter->emit()                                                                               
     #25 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):         
     _PHPStan_42eac28f8\Clue\React\NDJson\Decoder->handleData()                                                                      
     #26 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62):                              
     _PHPStan_42eac28f8\Evenement\EventEmitter->emit()                                                                               
     #27 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/EventEmitterTrait.php(111):         
     _PHPStan_42eac28f8\React\Stream\Util::_PHPStan_42eac28f8\React\Stream\{closure}()                                               
     #28 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(168):             
     _PHPStan_42eac28f8\Evenement\EventEmitter->emit()                                                                               
     #29 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):             
     _PHPStan_42eac28f8\React\Stream\DuplexResourceStream->handleData()                                                              
     #30 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):             
     _PHPStan_42eac28f8\React\EventLoop\StreamSelectLoop->waitForStreamActivity()                                                    
     #31 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(105):                                
     _PHPStan_42eac28f8\React\EventLoop\StreamSelectLoop->run()                                                                      
     #32 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):                   
     PHPStan\Command\WorkerCommand->execute()                                                                                        
     #33 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(868):                       
     _PHPStan_42eac28f8\Symfony\Component\Console\Command\Command->run()                                                             
     #34 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(261):                       
     _PHPStan_42eac28f8\Symfony\Component\Console\Application->doRunCommand()                                                        
     #35 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):                       
     _PHPStan_42eac28f8\Symfony\Component\Console\Application->doRun()                                                               
     #36 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(93):                                                   
     _PHPStan_42eac28f8\Symfony\Component\Console\Application->run()                                                                 
     #37 phar:///var/www/html/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(94): _PHPStan_42eac28f8\{closure}()                    
     #38 /var/www/html/vendor/phpstan/phpstan/phpstan(8): require('...')                                                             
     #39 /var/www/html/vendor/bin/phpstan(119): include('...')                                                                       
     #40 {main}                                                   

Code snippet that reproduces the problem

No response

Expected output

No internal error, and maybe a file and line to what needs addressing.

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions