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

Lines changed: 4 additions & 15 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,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

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

@@ -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

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 & 10 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

@@ -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

Lines changed: 5 additions & 16 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.
@@ -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

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy