8000 Make dispatched events really final by Tobion · Pull Request #33297 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Make dispatched events really final #33297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions src/Symfony/Component/Console/Event/ConsoleCommandEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
* Allows to do things before the command is executed, like skipping the command or changing the input.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
*/
class ConsoleCommandEvent extends ConsoleEvent
final class ConsoleCommandEvent extends ConsoleEvent
{
/**
* The return code for skipped commands, this will also be passed into the terminate event.
Expand All @@ -32,30 +30,21 @@ class ConsoleCommandEvent extends ConsoleEvent

/**
* Disables the command, so it won't be run.
*
* @return bool
*/
public function disableCommand()
public function disableCommand(): bool
{
return $this->commandShouldRun = false;
}

/**
* Enables the command.
*
* @return bool
*/
public function enableCommand()
public function enableCommand(): bool
{
return $this->commandShouldRun = true;
}

/**
* Returns true if the command is runnable, false otherwise.
*
* @return bool
*/
public function commandShouldRun()
public function commandShouldRun(): bool
{
return $this->commandShouldRun;
}
Expand Down
20 changes: 4 additions & 16 deletions src/Symfony/Component/Console/Event/ConsoleTerminateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
* Allows to manipulate the exit code of a command after its execution.
*
* @author Francesco Levorato <git@flevour.net>
*
* @final since Symfony 4.4
*/
class ConsoleTerminateEvent extends ConsoleEvent
final class ConsoleTerminateEvent extends ConsoleEvent
{
private $exitCode;

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

/**
* Sets the exit code.
*
* @param int $exitCode The command exit code
*/
public function setExitCode($exitCode)
public function setExitCode(int $exitCode): void
{
$this->exitCode = (int) $exitCode;
$this->exitCode = $exitCode;
}

/**
* Gets the exit code.
*
* @return int The command exit code
*/
public function getExitCode()
public function getExitCode(): int
{
return $this->exitCode;
}
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Event/PostSetDataEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
* This event is dispatched at the end of the Form::setData() method.
*
* This event is mostly here for reading data after having pre-populated the form.
*
* @final since Symfony 4.4
*/
class PostSetDataEvent extends FormEvent
final class PostSetDataEvent extends FormEvent
{
}
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Event/PostSubmitEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
* once the model and view data have been denormalized.
*
* It can be used to fetch data after denormalization.
*
* @final since Symfony 4.4
*/
class PostSubmitEvent extends FormEvent
final class PostSubmitEvent extends FormEvent
{
}
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Event/PreSetDataEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
* It can be used to:
* - Modify the data given during pre-population;
* - Modify a form depending on the pre-populated data (adding or removing fields dynamically).
*
* @final since Symfony 4.4
*/
class PreSetDataEvent extends FormEvent
final class PreSetDataEvent extends FormEvent
{
}
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Event/PreSubmitEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
* It can be used to:
* - Change data from the request, before submitting the data to the form.
* - Add or remove form fields, before submitting the data to the form.
*
* @final since Symfony 4.4
*/
class PreSubmitEvent extends FormEvent
final class PreSubmitEvent extends FormEvent
{
}
4 changes: 1 addition & 3 deletions src/Symfony/Component/Form/Event/SubmitEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
* transforms back the normalized data to the model and view data.
*
* It can be used to change data from the normalized representation of the data.
*
* @final since Symfony 4.4
*/
class SubmitEvent extends FormEvent
final class SubmitEvent extends FormEvent
{
}
13 changes: 3 additions & 10 deletions src/Symfony/Component/HttpKernel/Event/ControllerEvent.php
F438
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
* Controllers should be callables.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @final since Symfony 4.4
*/
class ControllerEvent extends KernelEvent
final class ControllerEvent extends KernelEvent
{
private $controller;

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

/**
* Returns the current controller.
*
* @return callable
*/
public function getController()
public function getController(): callable
{
return $this->controller;
}

public function setController(callable $controller)
public function setController(callable $controller): void
{
$this->controller = $controller;
}
Expand Down
21 changes: 5 additions & 16 deletions src/Symfony/Component/HttpKernel/Event/ExceptionEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
* event.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @final since Symfony 4.4
*/
class ExceptionEvent extends RequestEvent
final class ExceptionEvent extends RequestEvent
{
/**
* The exception object.
Expand All @@ -50,12 +48,7 @@ public function __construct(HttpKernelInterface $kernel, Request $request, int $
$this->setException($e);
}

/**
* Returns the thrown exception.
*
* @return \Exception The thrown exception
*/
public function getException()
public function getException(): \Exception
{
return $this->exception;
}
Expand All @@ -64,28 +57,24 @@ public function getException()
* Replaces the thrown exception.
*
* This exception will be thrown if no response is set in the event.
*
* @param \Exception $exception The thrown exception
*/
public function setException(\Exception $exception)
public function setException(\Exception $exception): void
{
$this->exception = $exception;
}

/**
* Mark the event as allowing a custom response code.
*/
public function allowCustomResponseCode()
public function allowCustomResponseCode(): void
{
$this->allowCustomResponseCode = true;
}

/**
* Returns true if the event allows a custom response code.
*
* @return bool
*/
public function isAllowingCustomResponseCode()
public function isAllowingCustomResponseCode(): bool
{
return $this->allowCustomResponseCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
* Triggered whenever a request is fully processed.
*
* @author Benjamin Eberlei <kontakt@beberlei.de>
*
* @final since Symfony 4.4
*/
class FinishRequestEvent extends KernelEvent
final class FinishRequestEvent extends KernelEvent
{
}
13 changes: 3 additions & 10 deletions src/Symfony/Component/HttpKernel/Event/ResponseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
* browser.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @final since Symfony 4.4
*/
class ResponseEvent extends KernelEvent
final class ResponseEvent extends KernelEvent
{
private $response;

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

/**
* Returns the current response object.
*
* @return Response
*/
public function getResponse()
public function getResponse(): Response
{
return $this->response;
}

public function setResponse(Response $response)
public function setResponse(Response $response): void
{
$this->response = $response;
}
Expand Down
11 changes: 2 additions & 9 deletions src/Symfony/Component/HttpKernel/Event/TerminateEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
* will always return the value of `HttpKernelInterface::MASTER_REQUEST`.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*
* @final since Symfony 4.4
*/
class TerminateEvent extends KernelEvent
final class TerminateEvent extends KernelEvent
{
private $response;

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

/**
* Returns the response for which this event was thrown.
*
* @return Response
*/
public function getResponse()
public function getResponse(): Response
{
return $this->response;
}
Expand Down
6 changes: 2 additions & 4 deletions src/Symfony/Component/HttpKernel/Event/ViewEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
* response is set.
*
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @final since Symfony 4.4
*/
class ViewEvent extends RequestEvent
final class ViewEvent extends RequestEvent
{
/**
* The return value of the controller.
Expand Down Expand Up @@ -56,7 +54,7 @@ public function getControllerResult()
*
* @param mixed $controllerResult The controller return value
*/
public function setControllerResult($controllerResult)
public function setControllerResult($controllerResult): void
{
$this->controllerResult = $controllerResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* This event is dispatched on authentication failure.
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*
* @final since Symfony 4.4
*/
class AuthenticationFailureEvent extends AuthenticationEvent
final class AuthenticationFailureEvent extends AuthenticationEvent
{
private $authenticationException;

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

public function getAuthenticationException()
public function getAuthenticationException(): AuthenticationException
{
return $this->authenticationException;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

namespace Symfony\Component\Security\Core\Event;

/**
* @final since Symfony 4.4
*/
class AuthenticationSuccessEvent extends AuthenticationEvent
final class AuthenticationSuccessEvent extends AuthenticationEvent
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@
* Deauthentication happens in case the user has changed when trying to refresh the token.
*
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
*
* @final since Symfony 4.4
*/
class DeauthenticatedEvent extends Event
final class DeauthenticatedEvent extends Event
{
private $originalToken;
private $refreshedToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@

/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @final since Symfony 4.4
*/
class InteractiveLoginEvent extends Event
final class InteractiveLoginEvent extends Event
{
private $request;
private $authenticationToken;
Expand All @@ -31,22 +29,12 @@ public function __construct(Request $request, TokenInterface $authenticationToke
$this->authenticationToken = $authenticationToken;
}

/**
* Gets the request.
*
* @return Request A Request instance
*/
public function getRequest()
public function getRequest(): Request
{
return $this->request;
}

/**
* Gets the authentication token.
*
* @return TokenInterface A TokenInterface instance
*/
public function getAuthenticationToken()
public function getAuthenticationToken(): TokenInterface
{
return $this->authenticationToken;
}
Expand Down
Loading
0