-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] AuthenticationUtils::getLastUsername() return type inconsistency #23409
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
Conversation
This would break every single |
@iltar , what if it always returns an nonempty string or null? This shouldn't break BC |
The case that the session is not set, is one that in theory should not happen frequently |
@iltar , I agree. But that's how it was done before, the My point is to make returning type consistent and more DX-friendly. |
Not sure it will be accepted for 2.8, but +1 for this API :) edit; on 2nd though |
Given that username should never be empty, I would prefer |
In any case, that would be for 3.4. |
While username may not be empty, the "last" one might not exist (yet). Hence it's a nullable imo. |
Right, if there is no last username, it's an empty string. |
What about the case where the input type was named wrongly (e.g. |
Let's finish this PR? |
👍 as well for always string (means session default changes) |
I agree with @ro0NL - return a string always. |
Same for me 👍 for a string return. |
Rebased onto |
But I think we should merge this into |
Could this be merged or smth else needs to be done? |
Perhaps add a changelog entry? |
Rebased, squashed, added a changelog entry, changed base to master, ready to merge :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think we should document this change in the upgrade file for 4.1 too. |
Ready! |
Thank you @vudaltsov. |
…rn type inconsistency (vudaltsov) This PR was merged into the 4.1-dev branch. Discussion ---------- [Security] AuthenticationUtils::getLastUsername() return type inconsistency Always return `string`, never `null` according to the `@return` annotation tag. | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Alternatively, string return might be nullable: ```php return null === $session ? null : $session->get(Security::LAST_USERNAME); ``` Is test needed for this change? Commits ------- 743692c AuthenticationUtils::getLastUsername()` now always returns a string.
Always return
string
, nevernull
according to the@return
annotation tag.Alternatively, string return might be nullable:
Is test needed for this change?