Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[make:registration] use "User" type in EmailVerifier::class #1519

Merged
merged 1 commit into from
Apr 21, 2024

Conversation

jrushlow
Copy link
Collaborator

sendEmailConfirmation() && handleEmailConfirmation() both have the $user type as UserInterface. This is pointless other than to ensure we get a "user" object. Seeing as we already know the class details of the "user" object, let's use the class short name instead of UserInterface when generating EmailVerifier. Improves phpstan in userland.

// in part

- public function sendEmailConfirmation(UserInterface $user)
+ public function sendEmailConfirmation(<?= $user_class_name ?> $userl)  // generated as "User"
  • adds (string) cast to getId() calls on the user object. In cases where the users id is an int, this will squash any squawks from phpstan about
Parameter #2 $userId of method SymfonyCasts\Bundle\VerifyEmail\VerifyEmailHelperInterface::generateSignature() expects string, int|null given. 

Edge Case

If the consumer has multiple "user" objects that use these methods (out of scope for MakerBundle), they can change the type manually to either User|AnotherUser $user || CustomUserInterface $user.

`sendEmailConfirmation()` && `handleEmailConfirmation()` both have the `$user` type as `UserInterface`. This is pointless other than to ensure we get a "user" object. Seeing as we already know the class details of the "user" object, let's use the class short name instead of `UserInterface` when generating `EmailVerifier`. Improves phpstan in userland.
@jrushlow jrushlow added Feature New Feature Status: Needs Review Needs to be reviewed labels Apr 19, 2024
@jrushlow jrushlow merged commit d711796 into symfony:main Apr 21, 2024
7 checks passed
@jrushlow jrushlow deleted the feature/verify-email-improvements branch April 21, 2024 00:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Feature New Feature Status: Needs Review Needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant