From 0602d110baea6c5d2a748294d61fcbe5ceb1dfb9 Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Tue, 19 Nov 2024 17:48:35 +0100 Subject: [PATCH] Add PHP 8.4 compatibility, add tests --- .github/workflows/php.yml | 36 +++++++++++++++++++++--- src/AdvancedCircuitBreaker.php | 4 +-- src/Client/SymfonyHttpClient.php | 2 +- src/Contract/CircuitBreakerInterface.php | 2 +- src/PartialCircuitBreaker.php | 4 +-- src/SimpleCircuitBreaker.php | 2 +- 6 files changed, 39 insertions(+), 11 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 1b8bc8d..d2c5b3b 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -52,7 +52,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] steps: - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -81,8 +81,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] - symfony-http-client-versions: ['5.4', '6.0', '6.1', '6.2'] + php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + symfony-http-client-versions: ['5.4', '6.0', '6.1', '6.2', '6.3', '6.4'] exclude: - php-versions: '7.2' symfony-http-client-versions: '6.0' @@ -106,6 +106,34 @@ jobs: symfony-http-client-versions: '6.2' - php-versions: '8.0' symfony-http-client-versions: '6.2' + - php-versions: '7.2' + symfony-http-client-versions: '6.3' + - php-versions: '7.3' + symfony-http-client-versions: '6.3' + - php-versions: '7.4' + symfony-http-client-versions: '6.3' + - php-versions: '8.0' + symfony-http-client-versions: '6.3' + - php-versions: '7.2' + symfony-http-client-versions: '6.4' + - php-versions: '7.3' + symfony-http-client-versions: '6.4' + - php-versions: '7.4' + symfony-http-client-versions: '6.4' + - php-versions: '8.0' + symfony-http-client-versions: '6.4' + - php-versions: '8.2' + symfony-http-client-versions: '5.4' + - php-versions: '8.2' + symfony-http-client-versions: '6.0' + - php-versions: '8.3' + symfony-http-client-versions: '5.4' + - php-versions: '8.3' + symfony-http-client-versions: '6.0' + - php-versions: '8.4' + symfony-http-client-versions: '5.4' + - php-versions: '8.4' + symfony-http-client-versions: '6.0' steps: - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/src/AdvancedCircuitBreaker.php b/src/AdvancedCircuitBreaker.php index 59a1b0b..a8f465b 100644 --- a/src/AdvancedCircuitBreaker.php +++ b/src/AdvancedCircuitBreaker.php @@ -63,7 +63,7 @@ public function __construct( public function call( $service, array $serviceParameters = [], - callable $fallback = null + ?callable $fallback = null ): string { $transaction = $this->initTransaction($service); @@ -124,7 +124,7 @@ public function setDefaultFallback(?callable $defaultFallback = null): self /** * {@inheritdoc} */ - protected function callFallback(callable $fallback = null): string + protected function callFallback(?callable $fallback = null): string { return parent::callFallback(null !== $fallback ? $fallback : $this->defaultFallback); } diff --git a/src/Client/SymfonyHttpClient.php b/src/Client/SymfonyHttpClient.php index 561be1f..59e6006 100644 --- a/src/Client/SymfonyHttpClient.php +++ b/src/Client/SymfonyHttpClient.php @@ -69,7 +69,7 @@ class SymfonyHttpClient implements ClientInterface */ private $client; - public function __construct(array $defaultOptions = [], HttpClientInterface $client = null) + public function __construct(array $defaultOptions = [], ?HttpClientInterface $client = null) { $this->defaultOptions = $defaultOptions; $this->client = $client; diff --git a/src/Contract/CircuitBreakerInterface.php b/src/Contract/CircuitBreakerInterface.php index 9132af3..71c5700 100644 --- a/src/Contract/CircuitBreakerInterface.php +++ b/src/Contract/CircuitBreakerInterface.php @@ -45,7 +45,7 @@ public function getState(): string; * @param array $parameters the parameters for the request * @param callable|null $fallback if the service is unavailable, rely on the fallback */ - public function call(string $service, array $parameters = [], callable $fallback = null): string; + public function call(string $service, array $parameters = [], ?callable $fallback = null): string; /** * @return bool checks if the circuit breaker is open diff --git a/src/PartialCircuitBreaker.php b/src/PartialCircuitBreaker.php index 9a589bd..d11836e 100644 --- a/src/PartialCircuitBreaker.php +++ b/src/PartialCircuitBreaker.php @@ -74,7 +74,7 @@ public function __construct( /** * {@inheritdoc} */ - abstract public function call(string $service, array $serviceParameters = [], callable $fallback = null): string; + abstract public function call(string $service, array $serviceParameters = [], ?callable $fallback = null): string; /** * {@inheritdoc} @@ -108,7 +108,7 @@ public function isClosed(): bool return State::CLOSED_STATE === $this->currentPlace->getState(); } - protected function callFallback(callable $fallback = null): string + protected function callFallback(?callable $fallback = null): string { if (null === $fallback) { return ''; diff --git a/src/SimpleCircuitBreaker.php b/src/SimpleCircuitBreaker.php index 017ca44..de456ba 100644 --- a/src/SimpleCircuitBreaker.php +++ b/src/SimpleCircuitBreaker.php @@ -56,7 +56,7 @@ public function __construct( public function call( string $service, array $serviceParameters = [], - callable $fallback = null + ?callable $fallback = null ): string { $transaction = $this->initTransaction($service); try {