Skip to content

Commit 953057f

Browse files
committed
Make dispatched events really final
1 parent bfdf79e commit 953057f

25 files changed

+50
-169
lines changed

src/Symfony/Component/Console/Event/ConsoleCommandEvent.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
* Allows to do things before the command is executed, like skipping the command or changing the input.
1616
*
1717
* @author Fabien Potencier <fabien@symfony.com>
18-
*
19-
* @final since Symfony 4.4
2018
*/
21-
class ConsoleCommandEvent extends ConsoleEvent
19+
final class ConsoleCommandEvent extends ConsoleEvent
2220
{
2321
/**
2422
* The return code for skipped commands, this will also be passed into the terminate event.
@@ -32,30 +30,21 @@ class ConsoleCommandEvent extends ConsoleEvent
3230

3331
/**
3432
* Disables the command, so it won't be run.
35-
*
36-
* @return bool
3733
*/
38-
public function disableCommand()
34+
public function disableCommand(): bool
3935
{
4036
return $this->commandShouldRun = false;
4137
}
4238

43-
/**
44-
* Enables the command.
45-
*
46-
* @return bool
47-
*/
48-
public function enableCommand()
39+
public function enableCommand(): bool
4940
{
5041
return $this->commandShouldRun = true;
5142
}
5243

5344
/**
5445
* Returns true if the command is runnable, false otherwise.
55-
*
56-
* @return bool
5746
*/
58-
public function commandShouldRun()
47+
public function commandShouldRun(): bool
5948
{
6049
return $this->commandShouldRun;
6150
}

src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php

+4-16
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919
* Allows to manipulate the exit code of a command after its execution.
2020
*
2121
* @author Francesco Levorato <git@flevour.net>
22-
*
23-
* @final since Symfony 4.4
2422
*/
25-
class ConsoleTerminateEvent extends ConsoleEvent
23+
final class ConsoleTerminateEvent extends ConsoleEvent
2624
{
2725
private $exitCode;
2826

@@ -33,22 +31,12 @@ public function __construct(Command $command, InputInterface $input, OutputInter
3331
$this->setExitCode($exitCode);
3432
}
3533

36-
/**
37-
* Sets the exit code.
38-
*
39-
* @param int $exitCode The command exit code
40-
*/
41-
public function setExitCode($exitCode)
34+
public function setExitCode(int $exitCode): void
4235
{
43-
$this->exitCode = (int) $exitCode;
36+
$this->exitCode = $exitCode;
4437
}
4538

46-
/**
47-
* Gets the exit code.
48-
*
49-
* @return int The command exit code
50-
*/
51-
public function getExitCode()
39+
public function getExitCode(): int
5240
{
5341
return $this->exitCode;
5442
}

src/Symfony/Component/Form/Event/PostSetDataEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
* This event is dispatched at the end of the Form::setData() method.
1818
*
1919
* This event is mostly here for reading data after having pre-populated the form.
20-
*
21-
* @final since Symfony 4.4
2220
*/
23-
class PostSetDataEvent extends FormEvent
21+
final class PostSetDataEvent extends FormEvent
2422
{
2523
}

src/Symfony/Component/Form/Event/PostSubmitEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
* once the model and view data have been denormalized.
1919
*
2020
* It can be used to fetch data after denormalization.
21-
*
22-
* @final since Symfony 4.4
2321
*/
24-
class PostSubmitEvent extends FormEvent
22+
final class PostSubmitEvent extends FormEvent
2523
{
2624
}

src/Symfony/Component/Form/Event/PreSetDataEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
* It can be used to:
2020
* - Modify the data given during pre-population;
2121
* - Modify a form depending on the pre-populated data (adding or removing fields dynamically).
22-
*
23-
* @final since Symfony 4.4
2422
*/
25-
class PreSetDataEvent extends FormEvent
23+
final class PreSetDataEvent extends FormEvent
2624
{
2725
}

src/Symfony/Component/Form/Event/PreSubmitEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
* It can be used to:
2020
* - Change data from the request, before submitting the data to the form.
2121
* - Add or remove form fields, before submitting the data to the form.
22-
*
23-
* @final since Symfony 4.4
2422
*/
25-
class PreSubmitEvent extends FormEvent
23+
final class PreSubmitEvent extends FormEvent
2624
{
2725
}

src/Symfony/Component/Form/Event/SubmitEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
* transforms back the normalized data to the model and view data.
1919
*
2020
* It can be used to change data from the normalized representation of the data.
21-
*
22-
* @final since Symfony 4.4
2321
*/
24-
class SubmitEvent extends FormEvent
22+
final class SubmitEvent extends FormEvent
2523
{
2624
}

src/Symfony/Component/HttpKernel/Event/ControllerEvent.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@
2424
* Controllers should be callables.
2525
*
2626
* @author Bernhard Schussek <bschussek@gmail.com>
27-
*
28-
* @final since Symfony 4.4
2927
*/
30-
class ControllerEvent extends KernelEvent
28+
final class ControllerEvent extends KernelEvent
3129
{
3230
private $controller;
3331

@@ -38,17 +36,12 @@ public function __construct(HttpKernelInterface $kernel, callable $controller, R
3836
$this->setController($controller);
3937
}
4038

41-
/**
42-
* Returns the current controller.
43-
*
44-
* @return callable
45-
*/
46-
public function getController()
39+
public function getController(): callable
4740
{
4841
return $this->controller;
4942
}
5043

51-
public function setController(callable $controller)
44+
public function setController(callable $controller): void
5245
{
5346
$this->controller = $controller;
5447
}

src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php

+5-16
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@
2626
* event.
2727
*
2828
* @author Bernhard Schussek <bschussek@gmail.com>
29-
*
30-
* @final since Symfony 4.4
3129
*/
32-
class ExceptionEvent extends RequestEvent
30+
final class ExceptionEvent extends RequestEvent
3331
{
3432
/**
3533
* The exception object.
@@ -50,12 +48,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, int $
5048
$this->setException($e);
5149
}
5250

53-
/**
54-
* Returns the thrown exception.
55-
*
56-
* @return \Exception The thrown exception
57-
*/
58-
public function getException()
51+
public function getException(): \Exception
5952
{
6053
return $this->exception;
6154
}
@@ -64,28 +57,24 @@ public function getException()
6457
* Replaces the thrown exception.
6558
*
6659
* This exception will be thrown if no response is set in the event.
67-
*
68-
* @param \Exception $exception The thrown exception
6960
*/
70-
public function setException(\Exception $exception)
61+
public function setException(\Exception $exception): void
7162
{
7263
$this->exception = $exception;
7364
}
7465

7566
/**
7667
* Mark the event as allowing a custom response code.
7768
*/
78-
public function allowCustomResponseCode()
69+
public function allowCustomResponseCode(): void
7970
{
8071
$this->allowCustomResponseCode = true;
8172
}
8273

8374
/**
8475
* Returns true if the event allows a custom response code.
85-
*
86-
* @return bool
8776
*/
88-
public function isAllowingCustomResponseCode()
77+
public function isAllowingCustomResponseCode(): bool
8978
{
9079
return $this->allowCustomResponseCode;
9180
}

src/Symfony/Component/HttpKernel/Event/FinishRequestEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
* Triggered whenever a request is fully processed.
1616
*
1717
* @author Benjamin Eberlei <kontakt@beberlei.de>
18-
*
19-
* @final since Symfony 4.4
2018
*/
21-
class FinishRequestEvent extends KernelEvent
19+
final class FinishRequestEvent extends KernelEvent
2220
{
2321
}

src/Symfony/Component/HttpKernel/Event/ResponseEvent.php

+3-10
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
* browser.
2424
*
2525
* @author Bernhard Schussek <bschussek@gmail.com>
26-
*
27-
* @final since Symfony 4.4
2826
*/
29-
class ResponseEvent extends KernelEvent
27+
final class ResponseEvent extends KernelEvent
3028
{
3129
private $response;
3230

@@ -37,17 +35,12 @@ public function __construct(HttpKernelInterface $kernel, Request $request, int $
3735
$this->setResponse($response);
3836
}
3937

40-
/**
41-
* Returns the current response object.
42-
*
43-
* @return Response
44-
*/
45-
public function getResponse()
38+
public function getResponse(): Response
4639
{
4740
return $this->response;
4841
}
4942

50-
public function setResponse(Response $response)
43+
public function setResponse(Response $response): void
5144
{
5245
$this->response = $response;
5346
}

src/Symfony/Component/HttpKernel/Event/TerminateEvent.php

+2-9
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
* will always return the value of `HttpKernelInterface::MASTER_REQUEST`.
2323
*
2424
* @author Jordi Boggiano <j.boggiano@seld.be>
25-
*
26-
* @final since Symfony 4.4
2725
*/
28-
class TerminateEvent extends KernelEvent
26+
final class TerminateEvent extends KernelEvent
2927
{
3028
private $response;
3129

@@ -36,12 +34,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, Respo
3634
$this->response = $response;
3735
}
3836

39-
/**
40-
* Returns the response for which this event was thrown.
41-
*
42-
* @return Response
43-
*/
44-
public function getResponse()
37+
public function getResponse(): Response
4538
{
4639
return $this->response;
4740
}

src/Symfony/Component/HttpKernel/Event/ViewEvent.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
* response is set.
2323
*
2424
* @author Bernhard Schussek <bschussek@gmail.com>
25-
*
26-
* @final since Symfony 4.4
2725
*/
28-
class ViewEvent extends RequestEvent
26+
final class ViewEvent extends RequestEvent
2927
{
3028
/**
3129
* The return value of the controller.
@@ -56,7 +54,7 @@ public function getControllerResult()
5654
*
5755
* @param mixed $controllerResult The controller return value
5856
*/
59-
public function setControllerResult($controllerResult)
57+
public function setControllerResult($controllerResult): void
6058
{
6159
$this->controllerResult = $controllerResult;
6260
}

src/Symfony/Component/Security/Core/Event/AuthenticationFailureEvent.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
* This event is dispatched on authentication failure.
1919
*
2020
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
21-
*
22-
* @final since Symfony 4.4
2321
*/
24-
class AuthenticationFailureEvent extends AuthenticationEvent
22+
final class AuthenticationFailureEvent extends AuthenticationEvent
2523
{
2624
private $authenticationException;
2725

@@ -32,7 +30,7 @@ public function __construct(TokenInterface $token, AuthenticationException $ex)
3230
$this->authenticationException = $ex;
3331
}
3432

35-
public function getAuthenticationException()
33+
public function getAuthenticationException(): AuthenticationException
3634
{
3735
return $this->authenticationException;
3836
}

src/Symfony/Component/Security/Core/Event/AuthenticationSuccessEvent.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111

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

14-
/**
15-
* @final since Symfony 4.4
16-
*/
17-
class AuthenticationSuccessEvent extends AuthenticationEvent
14+
final class AuthenticationSuccessEvent extends AuthenticationEvent
1815
{
1916
}

src/Symfony/Component/Security/Http/Event/DeauthenticatedEvent.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
* Deauthentication happens in case the user has changed when trying to refresh the token.
1919
*
2020
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
21-
*
22-
* @final since Symfony 4.4
2321
*/
24-
class DeauthenticatedEvent extends Event
22+
final class DeauthenticatedEvent extends Event
2523
{
2624
private $originalToken;
2725
private $refreshedToken;

src/Symfony/Component/Security/Http/Event/InteractiveLoginEvent.php

+3-15
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
/**
1919
* @author Fabien Potencier <fabien@symfony.com>
20-
*
21-
* @final since Symfony 4.4
2220
*/
23-
class InteractiveLoginEvent extends Event
21+
final class InteractiveLoginEvent extends Event
2422
{
2523
private $request;
2624
private $authenticationToken;
@@ -31,22 +29,12 @@ public function __construct(Request $request, TokenInterface $authenticationToke
3129
$this->authenticationToken = $authenticationToken;
3230
}
3331

34-
/**
35-
* Gets the request.
36-
*
37-
* @return Request A Request instance
38-
*/
39-
public function getRequest()
32+
public function getRequest(): Request
4033
{
4134
return $this->request;
4235
}
4336

44-
/**
45-
* Gets the authentication token.
46-
*
47-
* @return TokenInterface A TokenInterface instance
48-
*/
49-
public function getAuthenticationToken()
37+
public function getAuthenticationToken(): TokenInterface
5038
{
5139
return $this->authenticationToken;
5240
}

0 commit comments

Comments
 (0)