diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 98d21c6..55548cf 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -900,6 +900,12 @@ parameters: count: 1 path: src/Http/Middleware/ServerErrorHandler.php + - + message: '#^Binary operation "\." between non\-falsy\-string and array\\|string results in an error\.$#' + identifier: binaryOp.invalid + count: 1 + path: src/Http/UriTemplate.php + - message: '#^Method ShoppingFeed\\Sdk\\Http\\UriTemplate\:\:expand\(\) has no return type specified\.$#' identifier: missingType.return @@ -936,6 +942,12 @@ parameters: count: 1 path: src/Http/UriTemplate.php + - + message: '#^Parameter \#2 \$array of function implode expects array\, array\\|string\> given\.$#' + identifier: argument.type + count: 1 + path: src/Http/UriTemplate.php + - message: '#^Property ShoppingFeed\\Sdk\\Http\\UriTemplate\:\:\$delims type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue diff --git a/src/Client/Client.php b/src/Client/Client.php index 36a121e..aacbee0 100644 --- a/src/Client/Client.php +++ b/src/Client/Client.php @@ -14,19 +14,14 @@ class Client private $client; /** - * @param ClientOptions|null $options - * * @return \ShoppingFeed\Sdk\Api\Session\SessionResource */ - public static function createSession(CredentialInterface $credential, ClientOptions $options = null) + public static function createSession(CredentialInterface $credential, ?ClientOptions $options = null) { return (new self($options))->authenticate($credential); } - /** - * @param ClientOptions|null $options - */ - public function __construct(ClientOptions $options = null) + public function __construct(?ClientOptions $options = null) { if (null === $options) { $options = new ClientOptions(); diff --git a/src/Hal/HalLink.php b/src/Hal/HalLink.php index 5d694bd..ae00553 100644 --- a/src/Hal/HalLink.php +++ b/src/Hal/HalLink.php @@ -199,8 +199,8 @@ public function delete($data, array $variables = [], array $options = []) */ public function batchSend( $requests, - callable $success = null, - callable $error = null, + ?callable $success = null, + ?callable $error = null, array $options = [], $concurrency = 10, ) { @@ -255,11 +255,9 @@ public function createRequest($method, array $variables = [], $body = null, $hea } /** - * @param callable|null $callback - * * @return \Closure */ - private function createResponseCallback(callable $callback = null) + private function createResponseCallback(?callable $callback = null) { return function (ResponseInterface $response) use ($callback) { if ($callback) { @@ -270,11 +268,9 @@ private function createResponseCallback(callable $callback = null) } /** - * @param callable|null $callback - * * @return \Closure */ - private function createExceptionCallback(callable $callback = null) + private function createExceptionCallback(?callable $callback = null) { return function (Exception $exception) use ($callback) { call_user_func($callback, $exception); diff --git a/src/Http/Adapter/GuzzleHTTPAdapter.php b/src/Http/Adapter/GuzzleHTTPAdapter.php index ad09605..1dc0512 100644 --- a/src/Http/Adapter/GuzzleHTTPAdapter.php +++ b/src/Http/Adapter/GuzzleHTTPAdapter.php @@ -27,8 +27,8 @@ class GuzzleHTTPAdapter implements Http\Adapter\AdapterInterface private $pool; public function __construct( - Client\ClientOptions $options = null, - GuzzleHttp\HandlerStack $stack = null, + ?Client\ClientOptions $options = null, + ?GuzzleHttp\HandlerStack $stack = null, ) { $this->options = $options ?: new Client\ClientOptions(); $this->stack = $stack ?: $this->createHandlerStack(); @@ -106,11 +106,9 @@ public function withToken($token) } /** - * @param callable|null $callback - * * @return \Closure */ - private function createExceptionCallback(callable $callback = null) + private function createExceptionCallback(?callable $callback = null) { return function (GuzzleHttp\Exception\TransferException $exception) use ($callback) { if ($callback && $exception instanceof GuzzleHttp\Exception\RequestException && $exception->hasResponse()) { diff --git a/src/Http/Middleware/RateLimitHandler.php b/src/Http/Middleware/RateLimitHandler.php index e305551..778df9a 100644 --- a/src/Http/Middleware/RateLimitHandler.php +++ b/src/Http/Middleware/RateLimitHandler.php @@ -23,22 +23,20 @@ class RateLimitHandler private $logger; /** - * @param int $maxRetries - * @param LoggerInterface|null $logger + * @param int $maxRetries */ - public function __construct($maxRetries = 3, LoggerInterface $logger = null) + public function __construct($maxRetries = 3, ?LoggerInterface $logger = null) { $this->maxRetries = (int) $maxRetries; $this->logger = $logger; } /** - * @param int $count - * @param ResponseInterface|null $response + * @param int $count * * @return bool */ - public function decide($count, RequestInterface $request, ResponseInterface $response = null) + public function decide($count, RequestInterface $request, ?ResponseInterface $response = null) { if (! $response || $count >= $this->maxRetries) { return false; diff --git a/src/Http/Middleware/ServerErrorHandler.php b/src/Http/Middleware/ServerErrorHandler.php index 4f6fc5a..435af34 100644 --- a/src/Http/Middleware/ServerErrorHandler.php +++ b/src/Http/Middleware/ServerErrorHandler.php @@ -27,12 +27,11 @@ public function __construct($maxRetries = 3) } /** - * @param int $count - * @param ResponseInterface|null $response + * @param int $count * * @return bool */ - public function decide($count, RequestInterface $request, ResponseInterface $response = null) + public function decide($count, RequestInterface $request, ?ResponseInterface $response = null) { if ($count >= $this->maxRetries) { return false;