-
Notifications
You must be signed in to change notification settings - Fork 20
Deprecation found that is actually the solution to the problem #100
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
Comments
The issue is that
You can do that either in the original source code, or by providing a stub file: https://phpstan.org/user-guide/stub-files I'd accept these stubs in phpstan-symfony, ideally for all similar situations in Symfony at once. |
Static analysis tools like PHPStan treat the `@deprecated` flag as inherited. So when a class constant is marked as deprecated, then the same class constant in an extending class is also marked deprecated unless it gets explicitly marked as `@non-deprecated`. Without this flag PHPStan will return the message Fetching deprecated class constant LAST_USERNAME of class Symfony\Bundle\SecurityBundle\Security: since Symfony 6.2, use \Symfony\Bundle\SecurityBundle\Security::LAST_USERNAME instead which is not really helpful as that is exactly what one did at that point. By marking these class-constants as @non-deprecated PHPStan and other static analysis tools can recognize these class constants as being the rightly used ones. For more information have a look at the discussion at phpstan/phpstan-deprecation-rules#100
Static analysis tools like PHPStan treat the `@deprecated` flag as inherited. So when a class constant is marked as deprecated, then the same class constant in an extending class is also marked deprecated unless it gets explicitly marked as `@non-deprecated`. Without this flag PHPStan will return the message ``` Fetching deprecated class constant LAST_USERNAME of class Symfony\Bundle\SecurityBundle\Security: since Symfony 6.2, use \Symfony\Bundle\SecurityBundle\Security::LAST_USERNAME instead ``` which is not really helpful as that is exactly what one did at that point. By marking these class-constants as `@non-deprecated` PHPStan and other static analysis tools can recognize these class constants as being the rightly used ones. For more information have a look at the discussion at phpstan/phpstan-deprecation-rules#100
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. |
Uh oh!
There was an error while loading. Please reload this page.
I encountered a rather specific problem recently with the phpstan-deprecation-rule, more concrete with the
FetchingClassConstOfDeprecatedClassRule
.When I run phpstan over a sample project I get the following message:
This is somewhat puzzling...
I have prepared a small gist that one can check out to reproduce the issue:
git clone https://gist.github.com/ddb23f85813820a24c4cd26250d844ce.git cd ddb23f85813820a24c4cd26250d844ce composer install ./vendor/bin/phpstan
Sadly so far I wasn't able to track down where the issue is actually happening. I only dug down so far that the
\Symfony\Bundle\SecurityBundle\Security
class is extending a deprecated class and the\Symfony\Bundle\SecurityBundle\Security::LAST_USERNAME
const is overwriting the constant of the extended, deprecated, class.But it looks like there is more to it as trying to reproduce that with an exaple where I recreate the classes myself didn't work. So there seems to be a bit more involved.
When I comment out the
FetchingClassConstOfDeprecatedClassRule
in the config file of thephpstan-deprecation-rule
everything works as intended. So that one is for sure involved somehow...The text was updated successfully, but these errors were encountered: