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

Crash: Service 'rules.56' (type of PHPStan\Rules\Doctrine\ORM\DqlRule): Service of type PHPStan\Type\Doctrine\ObjectMetadataResolver needed by $objectMetadat aResolver in __construct() not found #51

Closed
josefsabl opened this issue Feb 13, 2019 · 6 comments

Comments

@josefsabl
Copy link

Hey, I just tried to enable these rules and get this crash:

In Autowiring.php line 190:
                                                                               
  Service 'rules.56' (type of PHPStan\Rules\Doctrine\ORM\DqlRule): Service of  
   type PHPStan\Type\Doctrine\ObjectMetadataResolver needed by $objectMetadat  
  aResolver in __construct() not found. Did you register it in configuration   
  file?                                                                                                                                                    

analyse [--paths-file PATHS-FILE] [-c|--configuration CONFIGURATION] [-l|--level LEVEL] [--no-progress] [--debug] [-a|--autoload-file AUTOLOAD-FILE] [--error-format ERROR-FORMAT] [--memory-limit MEMORY-LIMIT] [--] [<paths>...]

I have these things in composer.json

"phpstan/phpstan": "0.11.2",
"phpstan/phpstan-doctrine": "0.11.1",
"phpstan/phpstan-mockery": "0.11.0",
"phpstan/phpstan-nette": "0.11.0",
"thecodingmachine/phpstan-safe-rule": "0.1.2"

and dev-master nette.

It should be noted that I don't use ORM but ODM.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Feb 13, 2019 via email

@ondrejmirtes
Copy link
Member

I suspect you included only rules.neon but not extension.neon. Please follow the README how to use the extension.

@josefsabl
Copy link
Author

Correct, thank you! Silly me not RTFM, sorry :-/

But now I get:

Internal error: Class Doctrine\ORM\EntityRepository does not exist
Run PHPStan with --debug option and post the stack trace to:
https://github.com/phpstan/phpstan/issues/new

Obviously, because I don use ORM at all.

@ondrejmirtes
Copy link
Member

ondrejmirtes commented Feb 18, 2019 via email

@josefsabl
Copy link
Author

Can you show the stack trace as PHPStan recommmends?

Fatal error: Uncaught ReflectionException: Class Doctrine\ORM\EntityRepository does not exist in D:\projects\agfin\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php:334
Stack trace:
#0 D:\projects\agfin\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php(334): ReflectionClass->isSubclassOf('Doctrine\\ORM\\En...')
#1 D:\projects\agfin\vendor\phpstan\phpstan-doctrine\src\Reflection\Doctrine\EntityRepositoryClassReflectionExtension.php(14): PHPStan\Reflection\ClassReflection->isSubclassOf('Doctrine\\ORM\\En...')
#2 D:\projects\agfin\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php(196): PHPStan\Reflection\Doctrine\EntityRepositoryClassReflectionExtension->hasMethod(Object(PHPStan\Reflection\ClassReflection), 'startup')
#3 D:\projects\agfin\vendor\phpstan\phpstan\src\Rules\Methods\MethodSignatureRule.php(134): PHPStan\Reflection\ClassReflection->hasMethod('startup')
#4 *****\vendor\phpstan\phpstan\src\Rules\Methods\MethodSignatureRule.php(67): PHPStan\Rules\Methods\MethodSignatureRule->colle in *****\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php on line 334
PHP Fatal error:  Uncaught ReflectionException: Class Doctrine\ORM\EntityRepository does not exist in *****\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php:334
Stack trace:
#0 *****\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php(334): ReflectionClass->isSubclassOf('Doctrine\\ORM\\En...')
#1 *****\vendor\phpstan\phpstan-doctrine\src\Reflection\Doctrine\EntityRepositoryClassReflectionExtension.php(14): PHPStan\Reflection\ClassReflection->isSubclassOf('Doctrine\\ORM\\En...')
#2 *****\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php(196): PHPStan\Reflection\Doctrine\EntityRepositoryClassReflectionExtension->hasMethod(Object(PHPStan\Reflection\ClassReflection), 'startup')
#3 *****\vendor\phpstan\phpstan\src\Rules\Methods\MethodSignatureRule.php(134): PHPStan\Reflection\ClassReflection->hasMethod('startup')
#4 *****\vendor\phpstan\phpstan\src\Rules\Methods\MethodSignatureRule.php(67): PHPStan\Rules\Methods\MethodSignatureRule->colle in *****\vendor\phpstan\phpstan\src\Reflection\ClassReflection.php on line 334

Process finished with exit code 255

What does it mean that you don’t use the ORM? Just ODM?

Well, I don't have Doctrine\ORM installed, simple as that :-) We use Doctrine\ODM since our database is MongoDB.

And as the documentation states that this "Also supports Doctrine ODM." I thought I could use these rules to improve static analysis somehow and save some /** @var */ annotations.

This is all I have in my composer regarding Doctrine

    "doctrine/annotations": "1.6.0",
    "doctrine/common": "2.10.0",
    "doctrine/mongodb-odm": "2.0.0-beta1",

@github-actions
Copy link

github-actions bot commented May 2, 2021

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 May 2, 2021
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