Skip to content

Commit

Permalink
Adding compatibility for symfony/cache 7
Browse files Browse the repository at this point in the history
- symfony/cache 7 support
- phpstan 1.10
- updating php-cs-fixer
  • Loading branch information
roberto-butti committed Mar 5, 2024
1 parent 25ab14d commit fafcc75
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'concat_space' => ['spacing' => 'one'],
'visibility_required' => false,
'no_null_property_initialization' => false,
'static_lambda' => false
]);

$config->setFinder($finder);
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions src/Storyblok/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@
/**
* Storyblok Exception.
*/
class ApiException extends \Exception
{
}
class ApiException extends \Exception {}
18 changes: 8 additions & 10 deletions src/Storyblok/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -258,7 +256,7 @@ public function setCache($driver, $options = []): self
*
* @param string $slug Slug
*
* @return \Storyblok\Client
* @return Client
*/
public function deleteCacheBySlug($slug)
{
Expand All @@ -278,7 +276,7 @@ public function deleteCacheBySlug($slug)
/**
* Flush all cache.
*
* @return \Storyblok\Client
* @return Client
*/
public function flushCache()
{
Expand All @@ -296,7 +294,7 @@ public function flushCache()
* @param mixed $reset
* @param mixed $injectValue
*
* @return \Storyblok\Client
* @return Client
*/
public function setCacheVersion($reset = false, $injectValue = '')
{
Expand Down Expand Up @@ -390,7 +388,7 @@ public function getStoryByUuid($uuid)
*
* @param array $options Options
*
* @return \Storyblok\Client
* @return Client
*/
public function getStories($options = [])
{
Expand Down Expand Up @@ -482,7 +480,7 @@ public function resolveLinks($reference)
*
* @param array $options Options
*
* @return \Storyblok\Client
* @return Client
*/
public function getTags($options = [])
{
Expand Down Expand Up @@ -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 = [])
{
Expand Down Expand Up @@ -553,7 +551,7 @@ public function getDatasourceEntries($slug, $options = [])
*
* @param array $options Options
*
* @return \Storyblok\Client
* @return Client
*/
public function getLinks($options = [])
{
Expand Down Expand Up @@ -977,7 +975,7 @@ private function insertLinks($node)
*
* @param string $key Cache key
*
* @return \Storyblok\Client
* @return Client
*/
private function reCacheOnPublish($key)
{
Expand Down
7 changes: 4 additions & 3 deletions src/Storyblok/ManagementClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Storyblok;

use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\RequestOptions;

/**
Expand Down Expand Up @@ -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());
}
}
Expand Down Expand Up @@ -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());
}
}
Expand All @@ -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());
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/Client.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

use Storyblok\Client;

require '../vendor/autoload.php';

$client = new \Storyblok\Client('Iw3XKcJb6MwkdZEwoQ9BCQtt');
$client = new Client('Iw3XKcJb6MwkdZEwoQ9BCQtt');

// Optionally set a cache
$client->setCache('filesytem', ['path' => 'cache']);
Expand Down

0 comments on commit fafcc75

Please sign in to comment.