Closed VincentLanglet closed 2 weeks ago
Thank you.
Thanks @ondrejmirtes, do you think the api annotation can be added to the constructor too ? It would allows to write tests without the phpstan "error".:
Creating new PHPStan\Type\Doctrine\ObjectMetadataResolver is not covered by backward compatibility promise. The class might change in a minor PHPStan version.
Definitely not for the constructor. You should get the object from the container.
Definitely not for the constructor. You should get the object from the container.
Then how do I do for writing a Unit test like this one: https://github.com/phpstan/phpstan-doctrine/blob/2.0.x/tests/Rules/Doctrine/ORM/RepositoryMethodCallRuleTest.php#L17
?
You write a neon config and put the path in getAdditionalConfigFiles.
You write a neon config and put the path in getAdditionalConfigFiles.
Thanks a lot, i found an example with https://github.com/phpstan/phpstan-doctrine/blob/2.0.x/tests/Rules/Doctrine/ORM/MagicRepositoryMethodCallRuleTest.php
self::getContainer()->getByType()
works fine !
Solve https://github.com/phpstan/phpstan/discussions/11975
Since this method is used a lot in phpstan-doctrine rules, it should be allowed for developer to implements customs rule with it too.