Skip to content

Conversation

VincentLanglet
Copy link
Contributor

Solve phpstan/phpstan#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.

@ondrejmirtes ondrejmirtes merged commit 8ba0228 into phpstan:1.5.x Nov 9, 2024
44 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

@VincentLanglet
Copy link
Contributor Author

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.

#625

@ondrejmirtes
Copy link
Member

Definitely not for the constructor. You should get the object from the container.

@VincentLanglet
Copy link
Contributor Author

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

?

@ondrejmirtes
Copy link
Member

You write a neon config and put the path in getAdditionalConfigFiles.

@VincentLanglet
Copy link
Contributor Author

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants