From 78f7427813e28ee56c25a5ab440ed6800478870a Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 27 Mar 2024 23:48:10 +0100 Subject: [PATCH] explicitly mark nullable parameters as nullable --- src/Psr17Factory.php | 18 +++++++++--------- src/Psr18Client.php | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Psr17Factory.php b/src/Psr17Factory.php index 5d3ab92..f8fbfd1 100644 --- a/src/Psr17Factory.php +++ b/src/Psr17Factory.php @@ -49,12 +49,12 @@ class Psr17Factory implements RequestFactoryInterface, ResponseFactoryInterface, private $uriFactory; public function __construct( - RequestFactoryInterface $requestFactory = null, - ResponseFactoryInterface $responseFactory = null, - ServerRequestFactoryInterface $serverRequestFactory = null, - StreamFactoryInterface $streamFactory = null, - UploadedFileFactoryInterface $uploadedFileFactory = null, - UriFactoryInterface $uriFactory = null + ?RequestFactoryInterface $requestFactory = null, + ?ResponseFactoryInterface $responseFactory = null, + ?ServerRequestFactoryInterface $serverRequestFactory = null, + ?StreamFactoryInterface $streamFactory = null, + ?UploadedFileFactoryInterface $uploadedFileFactory = null, + ?UriFactoryInterface $uriFactory = null ) { $this->requestFactory = $requestFactory; $this->responseFactory = $responseFactory; @@ -98,7 +98,7 @@ public function createServerRequest(string $method, $uri, array $serverParams = return $factory->createServerRequest(...\func_get_args()); } - public function createServerRequestFromGlobals(array $server = null, array $get = null, array $post = null, array $cookie = null, array $files = null, StreamInterface $body = null): ServerRequestInterface + public function createServerRequestFromGlobals(?array $server = null, ?array $get = null, ?array $post = null, ?array $cookie = null, ?array $files = null, ?StreamInterface $body = null): ServerRequestInterface { $server = $server ?? $_SERVER; $request = $this->createServerRequest($server['REQUEST_METHOD'] ?? 'GET', $this->createUriFromGlobals($server), $server); @@ -134,7 +134,7 @@ public function createStreamFromResource($resource): StreamInterface return $factory->createStreamFromResource($resource); } - public function createUploadedFile(StreamInterface $stream, int $size = null, int $error = \UPLOAD_ERR_OK, string $clientFilename = null, string $clientMediaType = null): UploadedFileInterface + public function createUploadedFile(StreamInterface $stream, ?int $size = null, int $error = \UPLOAD_ERR_OK, ?string $clientFilename = null, ?string $clientMediaType = null): UploadedFileInterface { $factory = $this->uploadedFileFactory ?? $this->setFactory(Psr17FactoryDiscovery::findUploadedFileFactory()); @@ -148,7 +148,7 @@ public function createUri(string $uri = ''): UriInterface return $factory->createUri(...\func_get_args()); } - public function createUriFromGlobals(array $server = null): UriInterface + public function createUriFromGlobals(?array $server = null): UriInterface { return $this->buildUriFromGlobals($this->createUri(''), $server ?? $_SERVER); } diff --git a/src/Psr18Client.php b/src/Psr18Client.php index c47780e..26b6aeb 100644 --- a/src/Psr18Client.php +++ b/src/Psr18Client.php @@ -25,13 +25,13 @@ class Psr18Client extends Psr17Factory implements ClientInterface private $client; public function __construct( - ClientInterface $client = null, - RequestFactoryInterface $requestFactory = null, - ResponseFactoryInterface $responseFactory = null, - ServerRequestFactoryInterface $serverRequestFactory = null, - StreamFactoryInterface $streamFactory = null, - UploadedFileFactoryInterface $uploadedFileFactory = null, - UriFactoryInterface $uriFactory = null + ?ClientInterface $client = null, + ?RequestFactoryInterface $requestFactory = null, + ?ResponseFactoryInterface $responseFactory = null, + ?ServerRequestFactoryInterface $serverRequestFactory = null, + ?StreamFactoryInterface $streamFactory = null, + ?UploadedFileFactoryInterface $uploadedFileFactory = null, + ?UriFactoryInterface $uriFactory = null ) { parent::__construct($requestFactory, $responseFactory, $serverRequestFactory, $streamFactory, $uploadedFileFactory, $uriFactory);