From 6ae04a5fabc4e4c85014ac1d0a86f141f5b1e2f0 Mon Sep 17 00:00:00 2001 From: blmage Date: Wed, 3 Dec 2025 11:24:44 +0100 Subject: [PATCH 1/3] Fix PHP 8.4 deprecation errors --- src/Client/Client.php | 4 ++-- src/Hal/HalLink.php | 8 ++++---- src/Http/Adapter/GuzzleHTTPAdapter.php | 6 +++--- src/Http/Middleware/RateLimitHandler.php | 4 ++-- src/Http/Middleware/ServerErrorHandler.php | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Client/Client.php b/src/Client/Client.php index b83858b3..f6397630 100644 --- a/src/Client/Client.php +++ b/src/Client/Client.php @@ -20,7 +20,7 @@ class Client * * @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); } @@ -28,7 +28,7 @@ public static function createSession(CredentialInterface $credential, ClientOpti /** * @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 794ab871..e4a6cca9 100644 --- a/src/Hal/HalLink.php +++ b/src/Hal/HalLink.php @@ -227,8 +227,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 ) @@ -289,7 +289,7 @@ public function createRequest($method, array $variables = [], $body = null, $hea * * @return \Closure */ - private function createResponseCallback(callable $callback = null) + private function createResponseCallback(?callable $callback = null) { return function (ResponseInterface $response) use ($callback) { if ($callback) { @@ -304,7 +304,7 @@ private function createResponseCallback(callable $callback = null) * * @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 5e1099b6..6b644fcb 100644 --- a/src/Http/Adapter/GuzzleHTTPAdapter.php +++ b/src/Http/Adapter/GuzzleHTTPAdapter.php @@ -34,8 +34,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(); @@ -118,7 +118,7 @@ public function withToken($token) * * @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 25fcabbb..4e187d13 100644 --- a/src/Http/Middleware/RateLimitHandler.php +++ b/src/Http/Middleware/RateLimitHandler.php @@ -27,7 +27,7 @@ class RateLimitHandler * @param int $maxRetries * @param LoggerInterface|null $logger */ - public function __construct($maxRetries = 3, LoggerInterface $logger = null) + public function __construct($maxRetries = 3, ?LoggerInterface $logger = null) { $this->maxRetries = (int) $maxRetries; $this->logger = $logger; @@ -40,7 +40,7 @@ public function __construct($maxRetries = 3, LoggerInterface $logger = null) * * @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 5d5a62df..f2016820 100644 --- a/src/Http/Middleware/ServerErrorHandler.php +++ b/src/Http/Middleware/ServerErrorHandler.php @@ -32,7 +32,7 @@ public function __construct($maxRetries = 3) * * @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; From 6db50025f4a6730f114694164c50a4cf0d3ff5d3 Mon Sep 17 00:00:00 2001 From: Aurelieluciani Date: Wed, 15 Jul 2026 17:48:00 +0200 Subject: [PATCH 2/3] generate baseline --- phpstan-baseline.neon | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 98d21c68..55548cfc 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 From f84ce636cf600894d185517a7da591de91c853b9 Mon Sep 17 00:00:00 2001 From: Aurelieluciani Date: Wed, 15 Jul 2026 17:53:26 +0200 Subject: [PATCH 3/3] Fix CS --- src/Client/Client.php | 5 ----- src/Hal/HalLink.php | 4 ---- src/Http/Adapter/GuzzleHTTPAdapter.php | 4 +--- src/Http/Middleware/RateLimitHandler.php | 6 ++---- src/Http/Middleware/ServerErrorHandler.php | 3 +-- 5 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/Client/Client.php b/src/Client/Client.php index ddf6330d..aacbee0d 100644 --- a/src/Client/Client.php +++ b/src/Client/Client.php @@ -14,8 +14,6 @@ class Client private $client; /** - * @param ClientOptions|null $options - * * @return \ShoppingFeed\Sdk\Api\Session\SessionResource */ public static function createSession(CredentialInterface $credential, ?ClientOptions $options = null) @@ -23,9 +21,6 @@ public static function createSession(CredentialInterface $credential, ?ClientOpt return (new self($options))->authenticate($credential); } - /** - * @param ClientOptions|null $options - */ public function __construct(?ClientOptions $options = null) { if (null === $options) { diff --git a/src/Hal/HalLink.php b/src/Hal/HalLink.php index 167ad229..ae005538 100644 --- a/src/Hal/HalLink.php +++ b/src/Hal/HalLink.php @@ -255,8 +255,6 @@ public function createRequest($method, array $variables = [], $body = null, $hea } /** - * @param callable|null $callback - * * @return \Closure */ private function createResponseCallback(?callable $callback = null) @@ -270,8 +268,6 @@ private function createResponseCallback(?callable $callback = null) } /** - * @param callable|null $callback - * * @return \Closure */ private function createExceptionCallback(?callable $callback = null) diff --git a/src/Http/Adapter/GuzzleHTTPAdapter.php b/src/Http/Adapter/GuzzleHTTPAdapter.php index 629cd307..1dc05127 100644 --- a/src/Http/Adapter/GuzzleHTTPAdapter.php +++ b/src/Http/Adapter/GuzzleHTTPAdapter.php @@ -28,7 +28,7 @@ class GuzzleHTTPAdapter implements Http\Adapter\AdapterInterface public function __construct( ?Client\ClientOptions $options = null, - ?GuzzleHttp\HandlerStack $stack = null + ?GuzzleHttp\HandlerStack $stack = null, ) { $this->options = $options ?: new Client\ClientOptions(); $this->stack = $stack ?: $this->createHandlerStack(); @@ -106,8 +106,6 @@ public function withToken($token) } /** - * @param callable|null $callback - * * @return \Closure */ private function createExceptionCallback(?callable $callback = null) diff --git a/src/Http/Middleware/RateLimitHandler.php b/src/Http/Middleware/RateLimitHandler.php index c84159a6..778df9a6 100644 --- a/src/Http/Middleware/RateLimitHandler.php +++ b/src/Http/Middleware/RateLimitHandler.php @@ -23,8 +23,7 @@ class RateLimitHandler private $logger; /** - * @param int $maxRetries - * @param LoggerInterface|null $logger + * @param int $maxRetries */ public function __construct($maxRetries = 3, ?LoggerInterface $logger = null) { @@ -33,8 +32,7 @@ public function __construct($maxRetries = 3, ?LoggerInterface $logger = null) } /** - * @param int $count - * @param ResponseInterface|null $response + * @param int $count * * @return bool */ diff --git a/src/Http/Middleware/ServerErrorHandler.php b/src/Http/Middleware/ServerErrorHandler.php index 702b20a0..435af34e 100644 --- a/src/Http/Middleware/ServerErrorHandler.php +++ b/src/Http/Middleware/ServerErrorHandler.php @@ -27,8 +27,7 @@ public function __construct($maxRetries = 3) } /** - * @param int $count - * @param ResponseInterface|null $response + * @param int $count * * @return bool */