From da40d061b13ad53bf477cbd4c532cdf5a673d026 Mon Sep 17 00:00:00 2001 From: Andrej Rypo Date: Fri, 22 Nov 2024 09:44:24 +0100 Subject: [PATCH] PHP 8.4 nullable parameters fix --- src/CurrencyService.php | 4 ++-- src/Exceptions/MathException.php | 2 +- src/Exceptions/SetupException.php | 2 +- src/StaticExchange.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CurrencyService.php b/src/CurrencyService.php index 5638fd8..a36feef 100644 --- a/src/CurrencyService.php +++ b/src/CurrencyService.php @@ -22,7 +22,7 @@ class CurrencyService implements CurrencyServiceInterface, ExchangeServiceInterf protected $exchangeArgs = []; - public function __construct(ExchangeRateProviderInterface $exchange = null) + public function __construct(?ExchangeRateProviderInterface $exchange = null) { $exchange !== null && $this->setExchangeRateProvider($exchange); } @@ -262,7 +262,7 @@ public function getExchangeRateProvider(): ExchangeRateProviderInterface } - public function setExchangeRateProvider(ExchangeRateProviderInterface $exchange = null): self + public function setExchangeRateProvider(?ExchangeRateProviderInterface $exchange = null): self { $this->exchange = $exchange; return $this; diff --git a/src/Exceptions/MathException.php b/src/Exceptions/MathException.php index ca835d3..e3382b4 100644 --- a/src/Exceptions/MathException.php +++ b/src/Exceptions/MathException.php @@ -12,7 +12,7 @@ */ class MathException extends RuntimeException { - public function __construct($message = null, $code = null, Throwable $previous = null) + public function __construct($message = null, $code = null, ?Throwable $previous = null) { parent::__construct($message ?? '', $code ?? 0, $previous); } diff --git a/src/Exceptions/SetupException.php b/src/Exceptions/SetupException.php index 8a7ed3a..7957152 100644 --- a/src/Exceptions/SetupException.php +++ b/src/Exceptions/SetupException.php @@ -12,7 +12,7 @@ */ class SetupException extends LogicException { - public function __construct($message = null, $code = null, Throwable $previous = null) + public function __construct($message = null, $code = null, ?Throwable $previous = null) { parent::__construct($message ?? '', $code ?? 0, $previous); } diff --git a/src/StaticExchange.php b/src/StaticExchange.php index 6a78c36..0c351f6 100644 --- a/src/StaticExchange.php +++ b/src/StaticExchange.php @@ -71,7 +71,7 @@ public function __construct($referenceCurrency, array $exchangeRates, string $ex * @param CurrencyInterface $from * @return float|int */ - public function getExchangeRate(CurrencyInterface $target, CurrencyInterface $from = null) + public function getExchangeRate(CurrencyInterface $target, ?CurrencyInterface $from = null) { $getter = function (CurrencyInterface $target) { [$rate, $amount, $type] = $this->getRawExchangeRateSetup($target->code());