8000 Make dispatched events really final · symfony/symfony@b87d41d · GitHub
[go: up one dir, main page]

Skip to content

Commit b87d41d

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

25 files changed

+50
-142
lines changed

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

Lines changed: 4 additions & 12 deletions
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,24 @@ 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

4339
/**
4440
* Enables the command.
45-
*
46-
* @return bool
4741
*/
48-
public function enableCommand()
42+
public function enableCommand(): bool
4943
{
5044
return $this->commandShouldRun = true;
5145
}
5246

5347
/**
5448
* Returns true if the command is runnable, false otherwise.
55-
*
56-
* @return bool
5749
*/
58-
public function commandShouldRun()
50+
public function commandShouldRun(): bool
5951
{
6052
return $this->commandShouldRun;
6153
}

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

Lines changed: 4 additions & 10 deletions
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

@@ -35,20 +33,16 @@ public function __construct(Command $command, InputInterface $input, OutputInter
3533

3634
/**
3735
* Sets the exit code.
38-
*
39-
* @param int $exitCode The command exit code
4036
*/
41-
public function setExitCode($exitCode)
37+
public function setExitCode(int $exitCode): void
4238
{
43-
$this->exitCode = (int) $exitCode;
39+
$this->exitCode = $exitCode;
4440
}
4541

4642
/**
4743
* Gets the exit code.
48-
*
49-
* @return int The command exit code
5044
*/
51-
public function getExitCode()
45+
public function getExitCode(): int
5246
{
5347
return $this->exitCode;
5448
}

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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 7 deletions
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

@@ -40,15 +38,13 @@ public function __construct(HttpKernelInterface $kernel, callable $controller, R
4038

4139
/**
4240
* Returns the current controller.
43-
*
44-
* @return callable
4541
*/
46-
public function getController()
42+
public function getController(): callable
4743
{
4844
return $this->controller;
4945
}
5046

51-
public function setController(callable $controller)
47+
public function setController(callable $controller): void
5248
{
5349
$this->controller = $controller;
5450
}

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

Lines changed: 5 additions & 13 deletions
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.
@@ -52,10 +50,8 @@ public function __construct(HttpKernelInterface $kernel, Request $request, int $
5250

5351
/**
5452
* Returns the thrown exception.
55-
*
56-
* @return \Exception The thrown exception
5753
*/
58-
public function getException()
54+
public function getException(): \Exception
5955
{
6056
return $this->exception;
6157
}
@@ -64,28 +60,24 @@ public function getException()
6460
* Replaces the thrown exception.
6561
*
6662
* This exception will be thrown if no response is set in the event.
67-
*
68-
* @param \Exception $exception The thrown exception
6963
*/
70-
public function setException(\Exception $exception)
64+
public function setException(\Exception $exception): void
7165
{
7266
$this->exception = $exception;
7367
}
7468

7569
/**
7670
* Mark the event as allowing a custom response code.
7771
*/
78-
public function allowCustomResponseCode()
72+
public function allowCustomResponseCode(): void
7973
{
8074
$this->allowCustomResponseCode = true;
8175
}
8276

8377
/**
8478
* Returns true if the event allows a custom response code.
85-
*
86-
* @return bool
8779
*/
88-
public function isAllowingCustomResponseCode()
80+
public function isAllowingCustomResponseCode(): bool
8981
{
9082
return $this->allowCustomResponseCode;
9183
}

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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 7 deletions
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

@@ -39,15 +37,13 @@ public function __construct(HttpKernelInterface $kernel, Request $request, int $
3937

4038
/**
4139
* Returns the current response object.
42-
*
43-
* @return Response
4440
*/
45-
public function getResponse()
41+
public function getResponse(): Response
4642
{
4743
return $this->response;
4844
}
4945

50-
public function setResponse(Response $response)
46+
public function setResponse(Response $response): void
5147
{
5248
$this->response = $response;
5349
}

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

Lines changed: 2 additions & 6 deletions
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

@@ -38,10 +36,8 @@ public function __construct(HttpKernelInterface $kernel, Request $request, Respo
3836

3937
/**
4038
* Returns the response for which this event was thrown.
41-
*
42-
* @return Response
4339
*/
44-
public function getResponse()
40+
public function getResponse(): Response
4541
{
4642
return $this->response;
4743
}

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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 2 additions & 4 deletions
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(): 10000 AuthenticationException
3634
{
3735
return $this->authenticationException;
3836
}

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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 9 deletions
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;
@@ -33,20 +31,16 @@ public function __construct(Request $request, TokenInterface $authenticationToke
3331

3432
/**
3533
* Gets the request.
36-
*
37-
* @return Request A Request instance
3834
*/
39-
public function getRequest()
35+
public function getRequest(): Request
4036
{
4137
return $this->request;
4238
}
4339

4440
/**
4541
* Gets the authentication token.
46-
*
47-
* @return TokenInterface A TokenInterface instance
4842
*/
49-
public function getAuthenticationToken()
43+
public function getAuthenticationToken(): TokenInterface
5044
{
5145
return $this->authenticationToken;
5246
}

0 commit comments

Comments
 (0)
0