-
Notifications
You must be signed in to change notification settings - Fork 93
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
Narrow type with phpstan-assert even if we don't directly call the method for some Symfony class/interfaces. #325
Comments
|
Because it doesn't work like this https://phpstan.org/r/fb87f7e8-5e3d-4026-98a6-338fe3162b67 |
That doesn't make sense to me - you have no guarantee someone will call supports before calling voteOnAttribute. But if you want to enforce that, you can: https://phpstan.org/r/bc1e9de0-3dcb-466d-8b0d-e823a3c9f12f |
That's why I opened the issue in the Symfony plugin, because this specific class have the following comment: Symfony provide a lot of classes with a
With this, you have a strict-rule error for contravariant issues https://phpstan.org/r/b72f4692-b3a2-4281-93de-a8f740e5ce75 I wanted to avoid. |
There's no extension to change the current behaviour now.
Generics to the rescue: https://phpstan.org/r/51cce0fb-27ac-4fff-b9d4-214878850e54 (notice also there's no duplication of |
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. |
I recently got an idea for the following issue #179
For context, Symfony expose code which can resume to this:
So I'd like that, if I write
Do you think it's possible with some TypeSpecifier @ondrejmirtes ? I'm not familiar with this part of PHPStan.
If this logic is possible this could be later generalize to lot of other Symfony interfaces/classes.
The text was updated successfully, but these errors were encountered: