From d7a6a21202513ba8509c5fd92abc7b9fadf0d8db Mon Sep 17 00:00:00 2001 From: Hlavtox Date: Tue, 19 Nov 2024 17:48:35 +0100 Subject: [PATCH] Fix PHP 8.4 compatibility --- src/AdvancedCircuitBreaker.php | 4 ++-- src/Client/SymfonyHttpClient.php | 2 +- src/Contract/CircuitBreakerInterface.php | 2 +- src/PartialCircuitBreaker.php | 4 ++-- src/SimpleCircuitBreaker.php | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) 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 {