Skip to content

Commit 59e15a8

Browse files
feature #33152 Mark all dispatched event classes as final (Tobion)
This PR was merged into the 4.4 branch. Discussion ---------- Mark all dispatched event classes as final | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | | License | MIT | Doc PR | I think we should mark all our Event classes as final. There is no point in people extending them as the libraries that use the event, will only dispatch this event. So extending events in user-land achieves nothing as the subclasses won't be dispatched. I'm not talking about the base events that are meant to be extended like KernelEvent, but the leaf events like ExceptionEvent, ResponseEvent etc. Then we can also make them real final in 5.0 as the events are value objects that should not be mocked. Commits ------- 4bb38eec89 Mark all dispatched event classes as final
2 parents e61cf3a + 3cb0852 commit 59e15a8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Event/AuthenticationFailureEvent.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
* This event is dispatched on authentication failure.
1919
*
2020
* @author Johannes M. Schmitt <[email protected]>
21+
*
22+
* @final since Symfony 4.4
2123
*/
2224
class AuthenticationFailureEvent extends AuthenticationEvent
2325
{

Event/AuthenticationSuccessEvent.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
namespace Symfony\Component\Security\Core\Event;
1313

14+
/**
15+
* @final since Symfony 4.4
16+
*/
1417
class AuthenticationSuccessEvent extends AuthenticationEvent
1518
{
1619
}

Event/VoteEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @internal
2323
*/
24-
class VoteEvent extends Event
24+
final class VoteEvent extends Event
2525
{
2626
private $voter;
2727
private $subject;

0 commit comments

Comments
 (0)