8000 [Security] Implement fluent interface on RememberMeBadge::disable() by derrabus · Pull Request #41787 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Implement fluent interface on RememberMeBadge::disable() #41787

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

Merged
merged 1 commit into from
Jun 22, 2021

Conversation

derrabus
Copy link
Member
Q A
Branch? 5.3
Bug fix? yes
New feature? no
Deprecations? no
Tickets N/A
License MIT
Doc PR N/A

I was a bit puzzled when a I saw that RememberMeBadge::enable() implements a fluent interface while its counterpart disable() does not. This PR fixes this inconsistency.

The class is flagged as @final, so this change should not violate the BC promise.

Signed-off-by: Alexander M. Turek <me@derrabus.de>
@wouterj
Copy link
Member
wouterj commented Jun 22, 2021

While I'm OK with merging, is there a real use-case for disable being fluent? I mean, $badge->disabled()->isEnabled() doesn't make much sense, and there aren't any other methods in the badge?

The reason btw for enabled() being fluent is because the default is disabled. I like doing (new RememberMeBadge())->enabled() instead of having to use a variable.

@derrabus
Copy link
Member Author

I made this PR mainly to create a consistent behavior. The only use-case I can think of is a function that mutates and returns the badge, e.g.

return $badge->disable();

instead of

$badge->disable();

return $badge;

Copy link
Member
@wouterj wouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!

@derrabus derrabus merged commit 8dfdd89 into symfony:5.3 Jun 22, 2021
@fabpot fabpot mentioned this pull request Jun 30, 2021
@derrabus derrabus deleted the bugfix/remember-me-fluent-disable branch November 21, 2021 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
0