From fafcc75d8d266e4f4c4981e1c92ae100b4955bf6 Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Tue, 5 Mar 2024 17:26:22 +0100 Subject: [PATCH] Adding compatibility for symfony/cache 7 - symfony/cache 7 support - phpstan 1.10 - updating php-cs-fixer --- .php-cs-fixer.php | 1 + composer.json | 8 ++++---- src/Storyblok/ApiException.php | 4 +--- src/Storyblok/Client.php | 18 ++++++++---------- src/Storyblok/ManagementClient.php | 7 ++++--- tests/Client.php | 4 +++- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index c132135..1b650dc 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -27,6 +27,7 @@ 'concat_space' => ['spacing' => 'one'], 'visibility_required' => false, 'no_null_property_initialization' => false, + 'static_lambda' => false ]); $config->setFinder($finder); diff --git a/composer.json b/composer.json index 2ee5a43..c5c76f3 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,13 @@ "require": { "php": ">=7.3.0", "guzzlehttp/guzzle": "^7.4", - "symfony/cache": "^4.0|^5.0|^6.0", + "symfony/cache": "^4.0|^5.0|^6.0|^7.0", "ext-json": "*" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.4.0", "pestphp/pest": "1.21.2", - "phpstan/phpstan": "1.9.x-dev" + "phpstan/phpstan": "^1.10.59" }, "provide": { "psr/simple-cache-implementation": "1.0|2.0|3.0" @@ -52,8 +52,8 @@ "test-ci": "pest --ci", "phpstan": "phpstan analyse", "test-coverage": "pest --coverage", - "format": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --allow-risky=yes --using-cache=no", - "cs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --dry-run --using-cache=no", + "format": "php-cs-fixer fix --allow-risky=yes --using-cache=no", + "cs": "php-cs-fixer fix --dry-run --using-cache=no", "all-check": [ "@format", "@phpstan", diff --git a/src/Storyblok/ApiException.php b/src/Storyblok/ApiException.php index 30706b5..b1e6bb0 100644 --- a/src/Storyblok/ApiException.php +++ b/src/Storyblok/ApiException.php @@ -5,6 +5,4 @@ /** * Storyblok Exception. */ -class ApiException extends \Exception -{ -} +class ApiException extends \Exception {} diff --git a/src/Storyblok/Client.php b/src/Storyblok/Client.php index 90afd4c..a40dfba 100644 --- a/src/Storyblok/Client.php +++ b/src/Storyblok/Client.php @@ -206,8 +206,6 @@ public function getApiParameters() * * @param string $driver Driver * @param array $options Path for file cache - * - * @return \Storyblok\Client */ public function setCache($driver, $options = []): self { @@ -258,7 +256,7 @@ public function setCache($driver, $options = []): self * * @param string $slug Slug * - * @return \Storyblok\Client + * @return Client */ public function deleteCacheBySlug($slug) { @@ -278,7 +276,7 @@ public function deleteCacheBySlug($slug) /** * Flush all cache. * - * @return \Storyblok\Client + * @return Client */ public function flushCache() { @@ -296,7 +294,7 @@ public function flushCache() * @param mixed $reset * @param mixed $injectValue * - * @return \Storyblok\Client + * @return Client */ public function setCacheVersion($reset = false, $injectValue = '') { @@ -390,7 +388,7 @@ public function getStoryByUuid($uuid) * * @param array $options Options * - * @return \Storyblok\Client + * @return Client */ public function getStories($options = []) { @@ -482,7 +480,7 @@ public function resolveLinks($reference) * * @param array $options Options * - * @return \Storyblok\Client + * @return Client */ public function getTags($options = []) { @@ -514,7 +512,7 @@ public function getTags($options = []) * @param string $slug Slug * @param array $options Options * - * @return \Storyblok\Client + * @return Client */ public function getDatasourceEntries($slug, $options = []) { @@ -553,7 +551,7 @@ public function getDatasourceEntries($slug, $options = []) * * @param array $options Options * - * @return \Storyblok\Client + * @return Client */ public function getLinks($options = []) { @@ -977,7 +975,7 @@ private function insertLinks($node) * * @param string $key Cache key * - * @return \Storyblok\Client + * @return Client */ private function reCacheOnPublish($key) { diff --git a/src/Storyblok/ManagementClient.php b/src/Storyblok/ManagementClient.php index 18469a6..2c3644a 100644 --- a/src/Storyblok/ManagementClient.php +++ b/src/Storyblok/ManagementClient.php @@ -2,6 +2,7 @@ namespace Storyblok; +use GuzzleHttp\Exception\ClientException; use GuzzleHttp\RequestOptions; /** @@ -48,7 +49,7 @@ public function post($endpointUrl, $payload) $responseObj = $this->client->request('POST', $endpointUrl, $requestOptions); return $this->responseHandler($responseObj); - } catch (\GuzzleHttp\Exception\ClientException $e) { + } catch (ClientException $e) { throw new ApiException(self::EXCEPTION_GENERIC_HTTP_ERROR . ' - ' . $e->getMessage(), $e->getCode()); } } @@ -76,7 +77,7 @@ public function put($endpointUrl, $payload) $responseObj = $this->client->request('PUT', $endpointUrl, $requestOptions); return $this->responseHandler($responseObj); - } catch (\GuzzleHttp\Exception\ClientException $e) { + } catch (ClientException $e) { throw new ApiException(self::EXCEPTION_GENERIC_HTTP_ERROR . ' - ' . $e->getMessage(), $e->getCode()); } } @@ -102,7 +103,7 @@ public function delete($endpointUrl) $responseObj = $this->client->request('DELETE', $endpointUrl, $requestOptions); return $this->responseHandler($responseObj); - } catch (\GuzzleHttp\Exception\ClientException $e) { + } catch (ClientException $e) { throw new ApiException(self::EXCEPTION_GENERIC_HTTP_ERROR . ' - ' . $e->getMessage(), $e->getCode()); } } diff --git a/tests/Client.php b/tests/Client.php index f571877..539f02e 100644 --- a/tests/Client.php +++ b/tests/Client.php @@ -1,8 +1,10 @@ setCache('filesytem', ['path' => 'cache']);