From 6b1b6724ea26c21ea2b2c41b1e5e2b120227c46e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Mon, 27 Jan 2025 08:54:22 +0100 Subject: [PATCH] Fix implicit nullable parameter --- src/Bundle/Controller/ControllerTrait.php | 10 +++++----- .../HttpFoundation/HttpFoundationRequestHandler.php | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Bundle/Controller/ControllerTrait.php b/src/Bundle/Controller/ControllerTrait.php index 0076a8e7d..ae467f15d 100644 --- a/src/Bundle/Controller/ControllerTrait.php +++ b/src/Bundle/Controller/ControllerTrait.php @@ -143,7 +143,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co * * @final */ - protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse + protected function file($file, ?string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse { $response = new BinaryFileResponse($file); $response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName); @@ -236,7 +236,7 @@ protected function renderView(string $view, array $parameters = []): string protected function render( string $view, array $parameters = [], - Response $response = null, + ?Response $response = null, ?int $responseCode = null ): Response { if ($this->container->has('templating')) { @@ -266,7 +266,7 @@ protected function render( * * @final */ - protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse + protected function stream(string $view, array $parameters = [], ?StreamedResponse $response = null): StreamedResponse { if ($this->container->has('templating')) { @trigger_error('Using the "templating" service is deprecated since Symfony 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED); @@ -304,7 +304,7 @@ protected function stream(string $view, array $parameters = [], StreamedResponse * * @final */ - protected function createNotFoundException(string $message = 'Not Found', \Throwable $previous = null): NotFoundHttpException + protected function createNotFoundException(string $message = 'Not Found', ?\Throwable $previous = null): NotFoundHttpException { return new NotFoundHttpException($message, $previous); } @@ -320,7 +320,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Throw * * @final */ - protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException + protected function createAccessDeniedException(string $message = 'Access Denied.', ?\Throwable $previous = null): AccessDeniedException { if (!class_exists(AccessDeniedException::class)) { throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".'); diff --git a/src/Bundle/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php b/src/Bundle/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php index 078cc9f9c..23d183579 100644 --- a/src/Bundle/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php +++ b/src/Bundle/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php @@ -34,7 +34,7 @@ final class HttpFoundationRequestHandler implements RequestHandlerInterface { private ServerParams $serverParams; - public function __construct(ServerParams $serverParams = null) + public function __construct(?ServerParams $serverParams = null) { $this->serverParams = $serverParams ?: new ServerParams(); } @@ -42,7 +42,7 @@ public function __construct(ServerParams $serverParams = null) public function handleRequest(FormInterface $form, mixed $request = null): void { if (!$request instanceof Request) { - throw new UnexpectedTypeException($request, 'Symfony\Component\HttpFoundation\Request'); + throw new UnexpectedTypeException($request, Request::class); } $name = $form->getName();