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
}

0 commit comments

Comments
 (0)