-
Notifications
You must be signed in to change notification settings - Fork 92
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
Remove the generic type for PasswordUpgraderInterface #436
base: 1.4.x
Are you sure you want to change the base?
Conversation
This interface method can be called on a user provider even for user types not supported by that provider (for instance when using a chain provider). The implementation is expected to deal with that case gracefully, which will be enforced by phpstan when the generics are gone.
/cc @VincentLanglet You originally added this in #318. Do you agree with the removal? |
This is untrue when the chainProvider is not used, there is at least two implementations which doesn't deal with that case gracefully:
So currently when calling To be consistent those exception should be removed no @stof ?
Anyway, seem the original PR #318 was made to be sync with symfony/symfony#48750 |
Looking at the implementation of ChainUserProvider, the actual allowed behavior is either be silent or throw UnsupportedUserException (but not other exceptions) for unsupported users. But the implementation must still check what it gets as input (it cannot assume it always gets a supported user instance). |
Then the removal of the generic doesn't make sens in symfony/symfony#51283 and I feel wrong the fact the author or the team didn't ping me about the PR. When you use doctrine collection and write
returns a
without any error, except a static analysis one. It's the same with PasswordUpgraderInterface. It cannot fully guarantee that the User inside the method is the one expect but at least when calling You consider PasswordUpgraderInterface to be silent when a wrong user is passed, but it's true only for the ChainUserProvider not all implementations of the PasswordUpgraderInterface. To this to be true, we should change the
by a simple But even if Symfony is right or wrong on the removal of the Generic, PHPStan just have to follow to be in sync. |
@VincentLanglet the removal of the generic in core was done so that implementations of the interface are forced to consider that the user they receive might not be the type they support. With your generic type, phpstan would never tell you that your implementation is broken if you assume that |
With the |
@ondrejmirtes any chance to merge this ? |
This interface method can be called on a user provider even for user types not supported by that provider (for instance when using a chain provider). The implementation is expected to deal with that case gracefully, which will be enforced by phpstan when the generics are gone.
Closes #427
This reflects the removal done in Symfony 6.4 (reverting the PR adding it initially) so that the change done in Symfony to actually enforce correct implementations of that interface is also taken into account when adding this extension: symfony/symfony#51283