🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Array provided to ComposerJsonAndInstalledJsonSourceLocatorMaker::prefixPaths() #14724

Description

@trowski

Bug report

Hello!

I'm getting the following exception running 2.2.1 against a large codebase.

-- --------------------------------------------------------------------------- 
     Error                                                                      
 -- --------------------------------------------------------------------------- 
     Internal error:                                                            
     PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalle  
     dJsonSourceLocatorMaker::{closure:PHPStan\Reflection\BetterReflection\Sou  
     rceLocator\ComposerJsonAndInstalledJsonSourceLocatorMaker::prefixPaths():  
     193}(): Argument #1 ($path) must be of type string, array given while      
     analysing file                                                             
     {redacted}.php                                                                      
     Post the following stack trace to                                          
     https://github.com/phpstan/phpstan/issues/new?template=Bug_report.yaml:    
     ##                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceL  
     ocatorMaker.php(193)                                                       
     #0 [internal function]:                                                    
     PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalle  
     dJsonSourceLocatorMaker::{closure:PHPStan\Reflection\BetterReflection\Sou  
     rceLocator\ComposerJsonAndInstalledJsonSourceLocatorMaker::prefixPaths():  
     193}(Array)                                                                
     #1                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceL  
     ocatorMaker.php(193): array_map(Object(Closure), Array)                    
     #2                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceL  
     ocatorMaker.php(63):                                                       
     PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalle  
     dJsonSourceLocatorMaker->prefixPaths(Array, '/{redacted}...')          
     #3                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/BetterReflectionSourceLocatorFactory.php(162):     
     PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalle  
     dJsonSourceLocatorMaker->create('/{redacted}...')                      
     #4                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/SourceLocator/LazySourceLocator.php(26):           
     PHPStan\Reflection\BetterReflection\BetterReflectionSourceLocatorFactory-  
     >{closure:PHPStan\Reflection\BetterReflection\BetterReflectionSourceLoca   
     torFactory::create():131}()                                                
     #5                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/SourceLocator/LazySourceLocator.php(31):           
     PHPStan\Reflection\BetterReflection\SourceLocator\LazySourceLocator->laz   
     yInitialize()                                                              
     #6                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/o  
     ndrejmirtes/better-reflection/src/SourceLocator/Type/MemoizingSourceLocat  
     or.php(30):                                                                
     PHPStan\Reflection\BetterReflection\SourceLocator\LazySourceLocator->loc   
     ateIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector)  
     , Object(PHPStan\BetterReflection\Identifier\Identifier))                  
     #7                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/o  
     ndrejmirtes/better-reflection/src/Reflector/DefaultReflector.php(29):      
     PHPStan\BetterReflection\SourceLocator\Type\MemoizingSourceLocator->loca   
     teIdentifier(Object(PHPStan\BetterReflection\Reflector\DefaultReflector),  
     Object(PHPStan\BetterReflection\Identifier\Identifier))                    
     #8                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/Reflector/MemoizingReflector.php(50):              
     PHPStan\BetterReflection\Reflector\DefaultReflector->reflectClass('{reda
	 cted}...')                                                          
     #9                                                                         
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/BetterReflection/BetterReflectionProvider.php(145):                 
     PHPStan\Reflection\BetterReflection\Reflector\MemoizingReflector->reflec   
     tClass('{redacted}...')                                             
     #10                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Refl  
     ection/ReflectionProvider/MemoizingReflectionProvider.php(37):             
     PHPStan\Reflection\BetterReflection\BetterReflectionProvider->hasClass('   
     {redacted}...')                                                     
     #11                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Rule  
     s/ClassCaseSensitivityCheck.php(35):                                       
     PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider->hasCl   
     ass('{redacted}...')                                                
     #12                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Rule  
     s/ClassNameCheck.php(35):                                                  
     PHPStan\Rules\ClassCaseSensitivityCheck->checkClassNames(Array)            
     #13                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Rule  
     s/Namespaces/ExistingNamesInUseRule.php(116):                              
     PHPStan\Rules\ClassNameCheck->checkClassNames(Object(PHPStan\Analyser\Fi   
     ber\FiberScope), Array, NULL)                                              
     #14                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Rule  
     s/Namespaces/ExistingNamesInUseRule.php(64):                               
     PHPStan\Rules\Namespaces\ExistingNamesInUseRule->checkClasses(Object(PHP   
     Stan\Analyser\Fiber\FiberScope), Array)                                    
     #15                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/FileAnalyserCallback.php(134):                                        
     PHPStan\Rules\Namespaces\ExistingNamesInUseRule->processNode(Object(PhpP   
     arser\Node\Stmt\Use_), Object(PHPStan\Analyser\Fiber\FiberScope))          
     #16                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/Fiber/FiberNodeScopeResolver.php(37):                                 
     PHPStan\Analyser\FileAnalyserCallback->__invoke(Object(PhpParser\Node\St   
     mt\Use_), Object(PHPStan\Analyser\Fiber\FiberScope))                       
     #17 [internal function]:                                                   
     PHPStan\Analyser\Fiber\FiberNodeScopeResolver::{closure:PHPStan\Analyser\  
     Fiber\FiberNodeScopeResolver::callNodeCallback():34}()                     
     #18                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/Fiber/FiberNodeScopeResolver.php(41): Fiber->start()                  
     #19                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/NodeScopeResolver.php(641):                                           
     PHPStan\Analyser\Fiber\FiberNodeScopeResolver->callNodeCallback(Object(P   
     HPStan\Analyser\FileAnalyserCallback), Object(PhpParser\Node\Stmt\Use_),   
     Object(PHPStan\Analyser\MutatingScope),                                    
     Object(PHPStan\Analyser\ExpressionResultStorage))                          
     #20                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/NodeScopeResolver.php(410):                                           
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Nod   
     e\Stmt\Use_), Object(PHPStan\Analyser\MutatingScope),                      
     Object(PHPStan\Analyser\ExpressionResultStorage),                          
     Object(PHPStan\Analyser\FileAnalyserCallback),                             
     Object(PHPStan\Analyser\StatementContext))                                 
     #21                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Anal  
     yser/FileAnalyser.php(108):                                                
     PHPStan\Analyser\NodeScopeResolver->processNodes(Array,                    
     Object(PHPStan\Analyser\MutatingScope),                                    
     Object(PHPStan\Analyser\FileAnalyserCallback))                             
     #22                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Para  
     llel/WorkerRunner.php(129):                                                
     PHPStan\Analyser\FileAnalyser->analyseFile('/{redacted}...', Array,    
     Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry),   
     NULL)                                                                      
     #23                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/e  
     venement/evenement/src/EventEmitterTrait.php(111):                         
     PHPStan\Parallel\WorkerRunner::{closure:PHPStan\Parallel\WorkerRunner::ru  
     nWorker():105}(Array)                                                      
     #24                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/c  
     lue/ndjson-react/src/Decoder.php(117):                                     
     _PHPStan_f1a311097\Evenement\EventEmitter->emit('data', Array)             
     #25                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/e  
     venement/evenement/src/EventEmitterTrait.php(111):                         
     _PHPStan_f1a311097\Clue\React\NDJson\Decoder->handleData(Array)            
     #26                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/r  
     eact/stream/src/Util.php(62):                                              
     _PHPStan_f1a311097\Evenement\EventEmitter->emit('data', Array)             
     #27                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/e  
     venement/evenement/src/EventEmitterTrait.php(111):                         
     _PHPStan_f1a311097\React\Stream\Util::{closure:_PHPStan_f1a311097\React\S  
     tream\Util::forwardEvents():61}('{"action":"anal...')                      
     #28                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/r  
     eact/stream/src/DuplexResourceStream.php(168):                             
     _PHPStan_f1a311097\Evenement\EventEmitter->emit('data', Array)             
     #29                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/r  
     eact/event-loop/src/StreamSelectLoop.php(201):                             
     _PHPStan_f1a311097\React\Stream\DuplexResourceStream->handleData(Resourc   
     e id #8070)                                                                
     #30                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/r  
     eact/event-loop/src/StreamSelectLoop.php(173):                             
     _PHPStan_f1a311097\React\EventLoop\StreamSelectLoop->waitForStreamActivi   
     ty(NULL)                                                                   
     #31                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Para  
     llel/WorkerRunner.php(87):                                                 
     _PHPStan_f1a311097\React\EventLoop\StreamSelectLoop->run()                 
     #32                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/src/Comm  
     and/WorkerCommand.php(72):                                                 
     PHPStan\Parallel\WorkerRunner->run(Object(_PHPStan_f1a311097\Symfony\Com   
     ponent\Console\Output\ConsoleOutput), Array, 44453, '2pmyvg66cd', NULL,    
     NULL)                                                                      
     #33                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/s  
     ymfony/console/Command/Command.php(259):                                   
     PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_f1a311097\Symfony   
     \Component\Console\Input\ArgvInput),                                       
     Object(_PHPStan_f1a311097\Symfony\Component\Console\Output\ConsoleOutput)  
     )                                                                          
     #34                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/s  
     ymfony/console/Application.php(868):                                       
     _PHPStan_f1a311097\Symfony\Component\Console\Command\Command->run(Object   
     (_PHPStan_f1a311097\Symfony\Component\Console\Input\ArgvInput),            
     Object(_PHPStan_f1a311097\Symfony\Component\Console\Output\ConsoleOutput)  
     )                                                                          
     #35                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/s  
     ymfony/console/Application.php(261):                                       
     _PHPStan_f1a311097\Symfony\Component\Console\Application->doRunCommand(O   
     bject(PHPStan\Command\WorkerCommand),                                      
     Object(_PHPStan_f1a311097\Symfony\Component\Console\Input\ArgvInput),      
     Object(_PHPStan_f1a311097\Symfony\Component\Console\Output\ConsoleOutput)  
     )                                                                          
     #36                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/vendor/s  
     ymfony/console/Application.php(157):                                       
     _PHPStan_f1a311097\Symfony\Component\Console\Application->doRun(Object(_   
     PHPStan_f1a311097\Symfony\Component\Console\Input\ArgvInput),              
     Object(_PHPStan_f1a311097\Symfony\Component\Console\Output\ConsoleOutput)  
     )                                                                          
     #37                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/bin/phps  
     tan(106):                                                                  
     _PHPStan_f1a311097\Symfony\Component\Console\Application->run()            
     #38                                                                        
     phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar/bin/phps  
     tan(107):                                                                  
     {closure:phar:///{redacted}/vendor/phpstan/phpstan/phpstan.phar  
     /bin/phpstan:16}()                                                         
     #39 /{redacted}/vendor/phpstan/phpstan/phpstan(8):               
     require('phar:///{redacted}...')                                              
     #40 /{redacted}/vendor/bin/phpstan(119):                         
     include('/{redacted}...')                                              
     #41 {main}                                                                 
 -- --------------------------------------------------------------------------- 

Code snippet that reproduces the problem

No response

Expected output

No exception.

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