Make dispatched events really final
This commit is contained in:
parent
bfdf79e25d
commit
953057f28d
@ -15,10 +15,8 @@ namespace Symfony\Component\Console\Event;
|
||||
* 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.
|
||||
@ -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;
|
||||
}
|
||||
|
@ -19,10 +19,8 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
* 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;
|
||||
|
||||
@ -33,22 +31,12 @@ class ConsoleTerminateEvent extends ConsoleEvent
|
||||
$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;
|
||||
}
|
||||
|
@ -17,9 +17,7 @@ use Symfony\Component\Form\FormEvent;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -18,9 +18,7 @@ use Symfony\Component\Form\FormEvent;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ use Symfony\Component\Form\FormEvent;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -19,9 +19,7 @@ use Symfony\Component\Form\FormEvent;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -18,9 +18,7 @@ use Symfony\Component\Form\FormEvent;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -24,10 +24,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
* 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;
|
||||
|
||||
@ -38,17 +36,12 @@ class ControllerEvent extends KernelEvent
|
||||
$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;
|
||||
}
|
||||
|
@ -26,10 +26,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
* event.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ExceptionEvent extends RequestEvent
|
||||
final class ExceptionEvent extends RequestEvent
|
||||
{
|
||||
/**
|
||||
* The exception object.
|
||||
@ -50,12 +48,7 @@ class ExceptionEvent extends RequestEvent
|
||||
$this->setException($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the thrown exception.
|
||||
*
|
||||
* @return \Exception The thrown exception
|
||||
*/
|
||||
public function getException()
|
||||
public function getException(): \Exception
|
||||
{
|
||||
return $this->exception;
|
||||
}
|
||||
@ -64,10 +57,8 @@ class ExceptionEvent extends RequestEvent
|
||||
* 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;
|
||||
}
|
||||
@ -75,17 +66,15 @@ class ExceptionEvent extends RequestEvent
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
@ -15,9 +15,7 @@ namespace Symfony\Component\HttpKernel\Event;
|
||||
* 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
|
||||
{
|
||||
}
|
||||
|
@ -23,10 +23,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
* browser.
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class ResponseEvent extends KernelEvent
|
||||
final class ResponseEvent extends KernelEvent
|
||||
{
|
||||
private $response;
|
||||
|
||||
@ -37,17 +35,12 @@ class ResponseEvent extends KernelEvent
|
||||
$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;
|
||||
}
|
||||
|
@ -22,10 +22,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
* 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;
|
||||
|
||||
@ -36,12 +34,7 @@ class TerminateEvent extends KernelEvent
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the response for which this event was thrown.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getResponse()
|
||||
public function getResponse(): Response
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
@ -22,10 +22,8 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
* 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.
|
||||
@ -56,7 +54,7 @@ class ViewEvent extends RequestEvent
|
||||
*
|
||||
* @param mixed $controllerResult The controller return value
|
||||
*/
|
||||
public function setControllerResult($controllerResult)
|
||||
public function setControllerResult($controllerResult): void
|
||||
{
|
||||
$this->controllerResult = $controllerResult;
|
||||
}
|
||||
|
@ -18,10 +18,8 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||
* 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;
|
||||
|
||||
@ -32,7 +30,7 @@ class AuthenticationFailureEvent extends AuthenticationEvent
|
||||
$this->authenticationException = $ex;
|
||||
}
|
||||
|
||||
public function getAuthenticationException()
|
||||
public function getAuthenticationException(): AuthenticationException
|
||||
{
|
||||
return $this->authenticationException;
|
||||
}
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Security\Core\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class AuthenticationSuccessEvent extends AuthenticationEvent
|
||||
final class AuthenticationSuccessEvent extends AuthenticationEvent
|
||||
{
|
||||
}
|
||||
|
@ -18,10 +18,8 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
* 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;
|
||||
|
@ -17,10 +17,8 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class InteractiveLoginEvent extends Event
|
||||
final class InteractiveLoginEvent extends Event
|
||||
{
|
||||
private $request;
|
||||
private $authenticationToken;
|
||||
@ -31,22 +29,12 @@ class InteractiveLoginEvent extends Event
|
||||
$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;
|
||||
}
|
||||
|
@ -20,10 +20,8 @@ use Symfony\Contracts\EventDispatcher\Event;
|
||||
* SwitchUserEvent.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class SwitchUserEvent extends Event
|
||||
final class SwitchUserEvent extends Event
|
||||
{
|
||||
private $request;
|
||||
private $targetUser;
|
||||
@ -36,26 +34,17 @@ class SwitchUserEvent extends Event
|
||||
$this->token = $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Request
|
||||
*/
|
||||
public function getRequest()
|
||||
public function getRequest(): Request
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return UserInterface
|
||||
*/
|
||||
public function getTargetUser()
|
||||
public function getTargetUser(): UserInterface
|
||||
{
|
||||
return $this->targetUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TokenInterface|null
|
||||
*/
|
||||
public function getToken()
|
||||
public function getToken(): ?TokenInterface
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class AnnounceEvent extends Event
|
||||
final class AnnounceEvent extends Event
|
||||
{
|
||||
}
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class CompletedEvent extends Event
|
||||
final class CompletedEvent extends Event
|
||||
{
|
||||
}
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class EnterEvent extends Event
|
||||
final class EnterEvent extends Event
|
||||
{
|
||||
}
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class EnteredEvent extends Event
|
||||
final class EnteredEvent extends Event
|
||||
{
|
||||
}
|
||||
|
@ -20,10 +20,8 @@ use Symfony\Component\Workflow\WorkflowInterface;
|
||||
/**
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Grégoire Pineau <lyrixx@lyrixx.info>
|
||||
*
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class GuardEvent extends Event
|
||||
final class GuardEvent extends Event
|
||||
{
|
||||
private $transitionBlockerList;
|
||||
|
||||
@ -37,12 +35,12 @@ class GuardEvent extends Event
|
||||
$this->transitionBlockerList = new TransitionBlockerList();
|
||||
}
|
||||
|
||||
public function isBlocked()
|
||||
public function isBlocked(): bool
|
||||
{
|
||||
return !$this->transitionBlockerList->isEmpty();
|
||||
}
|
||||
|
||||
public function setBlocked(bool $blocked)
|
||||
public function setBlocked(bool $blocked): void
|
||||
{
|
||||
if (!$blocked) {
|
||||
$this->transitionBlockerList->clear();
|
||||
|
@ -11,9 +11,6 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class LeaveEvent extends Event
|
||||
final class LeaveEvent extends Event
|
||||
{
|
||||
}
|
||||
|
@ -11,14 +11,11 @@
|
||||
|
||||
namespace Symfony\Component\Workflow\Event;
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.4
|
||||
*/
|
||||
class TransitionEvent extends Event
|
||||
final class TransitionEvent extends Event
|
||||
{
|
||||
private $context;
|
||||
|
||||
public function setContext(array $context)
|
||||
public function setContext(array $context): void
|
||||
{
|
||||
$this->context = $context;
|
||||
}
|
||||
|
Reference in New Issue
Block a user