Skip to content

Commit 433b59a

Browse files
authored
Fix implicit nullable parameter (#977)
| Q | A | --------------- | ----- | Bug fix? | yes (fix deprecations) | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT Bc-layer seems ok https://3v4l.org/s8Mv1 https://3v4l.org/TastR
2 parents 0228f75 + 6b1b672 commit 433b59a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Bundle/Controller/ControllerTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ protected function json($data, int $status = 200, array $headers = [], array $co
143143
*
144144
* @final
145145
*/
146-
protected function file($file, string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse
146+
protected function file($file, ?string $fileName = null, string $disposition = ResponseHeaderBag::DISPOSITION_ATTACHMENT): BinaryFileResponse
147147
{
148148
$response = new BinaryFileResponse($file);
149149
$response->setContentDisposition($disposition, null === $fileName ? $response->getFile()->getFilename() : $fileName);
@@ -236,7 +236,7 @@ protected function renderView(string $view, array $parameters = []): string
236236
protected function render(
237237
string $view,
238238
array $parameters = [],
239-
Response $response = null,
239+
?Response $response = null,
240240
?int $responseCode = null
241241
): Response {
242242
if ($this->container->has('templating')) {
@@ -266,7 +266,7 @@ protected function render(
266266
*
267267
* @final
268268
*/
269-
protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse
269+
protected function stream(string $view, array $parameters = [], ?StreamedResponse $response = null): StreamedResponse
270270
{
271271
if ($this->container->has('templating')) {
272272
@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
304304
*
305305
* @final
306306
*/
307-
protected function createNotFoundException(string $message = 'Not Found', \Throwable $previous = null): NotFoundHttpException
307+
protected function createNotFoundException(string $message = 'Not Found', ?\Throwable $previous = null): NotFoundHttpException
308308
{
309309
return new NotFoundHttpException($message, $previous);
310310
}
@@ -320,7 +320,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Throw
320320
*
321321
* @final
322322
*/
323-
protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException
323+
protected function createAccessDeniedException(string $message = 'Access Denied.', ?\Throwable $previous = null): AccessDeniedException
324324
{
325325
if (!class_exists(AccessDeniedException::class)) {
326326
throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');

src/Bundle/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ final class HttpFoundationRequestHandler implements RequestHandlerInterface
3434
{
3535
private ServerParams $serverParams;
3636

37-
public function __construct(ServerParams $serverParams = null)
37+
public function __construct(?ServerParams $serverParams = null)
3838
{
3939
$this->serverParams = $serverParams ?: new ServerParams();
4040
}
4141

4242
public function handleRequest(FormInterface $form, mixed $request = null): void
4343
{
4444
if (!$request instanceof Request) {
45-
throw new UnexpectedTypeException($request, 'Symfony\Component\HttpFoundation\Request');
45+
throw new UnexpectedTypeException($request, Request::class);
4646
}
4747

4848
$name = $form->getName();

0 commit comments

Comments
 (0)