Skip to content

Error phpstan UUID Symfony #334

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

Closed
cymard opened this issue May 24, 2022 · 4 comments
Closed

Error phpstan UUID Symfony #334

cymard opened this issue May 24, 2022 · 4 comments

Comments

@cymard
Copy link

cymard commented May 24, 2022

Bug report

composer lib version

"phpstan/phpstan": "1.7.1",
"phpstan/phpstan-doctrine": "1.3.5",
"phpstan/phpstan-symfony": "1.1.8",

Code snippet that reproduces the problem

Documentation Symfony : https://symfony.com/doc/5.4/components/uid.html#storing-uuids-in-databases

class File
{
    #[ORM\Id]
    #[ORM\Column(type: 'uuid', unique: true)]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
    private ?Uuid $id;
}

Expected output

     Error                                                                                                                                                               
 -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
     Internal error: Internal error: Cannot instantiate custom generator : array (                                                                                       
       'class' => 'doctrine.uuid_generator',                                                                                                                             
     ) in file /src/Entity/File.php                                                                                                                     
                                                                                                                                                                         
     Post the following stack trace to https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md:                                                             
     #0 /srv/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(634): Doctrine\ORM\Mapping\Exception\InvalidCustomGenerator::onMissingClass(Array)    
     phpstan/phpstan#1 /srv/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(144):                                                                                 
     Doctrine\ORM\Mapping\ClassMetadataFactory->completeIdGeneratorMapping(Object(Doctrine\ORM\Mapping\ClassMetadata))                                                   
     phpstan/phpstan#2 /srv/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php(391):                                                                  
     Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL, false, Array)                                           
     phpstan/phpstan#3 /srv/vendor/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php(279):                                                                  
     Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('App\\Entity\\Tick...')                                                                     
     phpstan/phpstan#4 /srv/vendor/phpstan/phpstan-doctrine/src/Type/Doctrine/ObjectMetadataResolver.php(129):                                                                          
     Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('App\\Entity\\Tick...')                                                                   
     phpstan/phpstan#5 /srv/vendor/phpstan/phpstan-doctrine/src/Rules/Doctrine/ORM/PropertiesExtension.php(25):                                                                         
     PHPStan\Type\Doctrine\ObjectMetadataResolver->getClassMetadata('App\\Entity\\Tick...')                                                                              
     phpstan/phpstan#6 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Rules/DeadCode/UnusedPrivatePropertyRule.php(103):                                                           
     PHPStan\Rules\Doctrine\ORM\PropertiesExtension->isAlwaysRead(Object(PHPStan\Reflection\Php\PhpPropertyReflection), 'id')                                            
     phpstan/phpstan#7 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(102):                                                                              
     PHPStan\Rules\DeadCode\UnusedPrivatePropertyRule->processNode(Object(PHPStan\Node\ClassPropertiesNode), Object(PHPStan\Analyser\MutatingScope))                     
     phpstan/phpstan#8 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(570):                                                                         
     PHPStan\Analyser\FileAnalyser->PHPStan\Analyser\{closure}(Object(PHPStan\Node\ClassPropertiesNode), Object(PHPStan\Analyser\MutatingScope))                         
     phpstan/phpstan#9 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(323):                                                                         
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))                    
     phpstan/phpstan#10 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(535):                                                                        
     PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))        
     phpstan/phpstan#11 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(294):                                                                        
     PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))                
     phpstan/phpstan#12 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(189): PHPStan\Analyser\NodeScopeResolver->processNodes(Array,                     
     Object(PHPStan\Analyser\MutatingScope), Object(Closure))                                                                                                            
     phpstan/phpstan#13 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(143): PHPStan\Analyser\FileAnalyser->analyseFile('/srv/src/Entity...', Array,     
     Object(PHPStan\Rules\Registry), NULL)                                                                                                                               
     phpstan/phpstan#14 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                             
     PHPStan\Command\WorkerCommand->PHPStan\Command\{closure}(Array)                                                                                                     
     phpstan/phpstan#15 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/clue/ndjson-react/src/Decoder.php(110): _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data', Array)   
     phpstan/phpstan#16 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                             
     _PHPStan_c24aa5a16\Clue\React\NDJson\Decoder->handleData(Array)                                                                                                     
     phpstan/phpstan#17 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/Util.php(62): _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data', Array)            
     phpstan/phpstan#18 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/evenement/evenement/src/Evenement/EventEmitterTrait.php(97):                                             
     _PHPStan_c24aa5a16\React\Stream\Util::_PHPStan_c24aa5a16\React\Stream\{closure}('{"action":"anal...')                                                               
     phpstan/phpstan#19 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/react/stream/src/DuplexResourceStream.php(154): _PHPStan_c24aa5a16\Evenement\EventEmitter->emit('data',  
     Array)                                                                                                                                                              
     phpstan/phpstan#20 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(201):                                                          
     _PHPStan_c24aa5a16\React\Stream\DuplexResourceStream->handleData(Resource id phpstan/phpstan#3379)                                                                                 
     phpstan/phpstan#21 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/react/event-loop/src/StreamSelectLoop.php(173):                                                          
     _PHPStan_c24aa5a16\React\EventLoop\StreamSelectLoop->waitForStreamActivity(NULL)                                                                                    
     phpstan/phpstan#22 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/src/Command/WorkerCommand.php(106): _PHPStan_c24aa5a16\React\EventLoop\StreamSelectLoop->run()                  
     phpstan/phpstan#23 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259):                                                                
     PHPStan\Command\WorkerCommand->execute(Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),                                                        
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))                                                                                          
     phpstan/phpstan#24 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(856):                                                                    
     _PHPStan_c24aa5a16\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),                             
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))                                                                                          
     phpstan/phpstan#25 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259):                                                                    
     _PHPStan_c24aa5a16\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\WorkerCommand),                                                       
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))                    
     phpstan/phpstan#26 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157):                                                                    
     _PHPStan_c24aa5a16\Symfony\Component\Console\Application->doRun(Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Input\ArgvInput),                               
     Object(_PHPStan_c24aa5a16\Symfony\Component\Console\Output\ConsoleOutput))                                                                                          
     phpstan/phpstan#27 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(96): _PHPStan_c24aa5a16\Symfony\Component\Console\Application->run()                                
     phpstan/phpstan#28 phar:///srv/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(97): _PHPStan_c24aa5a16\{closure}()                                                                 
     phpstan/phpstan#29 /srv/vendor/phpstan/phpstan/phpstan(8): require('phar:///srv/ven...')                                                                                           
     phpstan/phpstan#30 {main}                                                                                                                                                          
     Child process error (exit code 1):                                                                                                                                  
 -- -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
@mergeable
Copy link

mergeable bot commented May 24, 2022

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

It will most likely be closed after manual review.

@ondrejmirtes ondrejmirtes transferred this issue from phpstan/phpstan May 24, 2022
@ondrejmirtes
Copy link
Member

Please try to configure objectManagerLoader in your project, it might help: https://github.com/phpstan/phpstan-doctrine#configuration

@cymard
Copy link
Author

cymard commented May 24, 2022

it's good. Thank you !

@cymard cymard closed this as completed May 24, 2022
@github-actions
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 Jun 25, 2022
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

2 participants