diff --git a/src/CurrencyConverter.php b/src/CurrencyConverter.php index 73ef6f4..5ed7cde 100644 --- a/src/CurrencyConverter.php +++ b/src/CurrencyConverter.php @@ -39,7 +39,7 @@ final class CurrencyConverter * @param Context|null $context A context to create the monies in, or null to use the default. * The context only applies to convert(), not convertToRational(). */ - public function __construct(ExchangeRateProvider $exchangeRateProvider, Context $context = null) + public function __construct(ExchangeRateProvider $exchangeRateProvider, ?Context $context = null) { if ($context === null) { $context = new DefaultContext(); diff --git a/src/Exception/CurrencyConversionException.php b/src/Exception/CurrencyConversionException.php index 274d077..30c0e82 100644 --- a/src/Exception/CurrencyConversionException.php +++ b/src/Exception/CurrencyConversionException.php @@ -41,7 +41,7 @@ public function __construct(string $message, string $sourceCurrencyCode, string * * @return CurrencyConversionException */ - public static function exchangeRateNotAvailable(string $sourceCurrencyCode, string $targetCurrencyCode, string $info = null) : self + public static function exchangeRateNotAvailable(string $sourceCurrencyCode, string $targetCurrencyCode, ?string $info = null) : self { $message = sprintf( 'No exchange rate available to convert %s to %s', diff --git a/src/Money.php b/src/Money.php index 9c05b77..dab608b 100644 --- a/src/Money.php +++ b/src/Money.php @@ -177,7 +177,7 @@ public static function create(BigNumber $amount, Currency $currency, Context $co * @throws NumberFormatException If the amount is a string in a non-supported format. * @throws RoundingNecessaryException If the rounding was necessary to represent the amount at the requested scale. */ - public static function of($amount, $currency, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money + public static function of($amount, $currency, ?Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money { if (! $currency instanceof Currency) { $currency = Currency::of($currency); @@ -209,7 +209,7 @@ public static function of($amount, $currency, Context $context = null, int $roun * @throws UnknownCurrencyException If the currency is an unknown currency code. * @throws MathException If the amount cannot be converted to a BigInteger. */ - public static function ofMinor($minorAmount, $currency, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money + public static function ofMinor($minorAmount, $currency, ?Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money { if (! $currency instanceof Currency) { $currency = Currency::of($currency); @@ -235,7 +235,7 @@ public static function ofMinor($minorAmount, $currency, Context $context = null, * * @return Money */ - public static function zero($currency, Context $context = null) : Money + public static function zero($currency, ?Context $context = null) : Money { if (! $currency instanceof Currency) { $currency = Currency::of($currency); @@ -613,7 +613,7 @@ public function negated() : Money * @throws UnknownCurrencyException If an unknown currency code is given. * @throws MathException If the exchange rate or rounding mode is invalid, or rounding is necessary. */ - public function convertedTo($currency, $exchangeRate, Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money + public function convertedTo($currency, $exchangeRate, ?Context $context = null, int $roundingMode = RoundingMode::UNNECESSARY) : Money { if (! $currency instanceof Currency) { $currency = Currency::of($currency); diff --git a/tests/AbstractTestCase.php b/tests/AbstractTestCase.php index f72b23a..2697380 100644 --- a/tests/AbstractTestCase.php +++ b/tests/AbstractTestCase.php @@ -52,7 +52,7 @@ final protected function assertMoneyEquals(string $expectedAmount, string $expec * * @return void */ - final protected function assertMoneyIs(string $expected, Money $actual, Context $context = null) : void + final protected function assertMoneyIs(string $expected, Money $actual, ?Context $context = null) : void { $this->assertSame($expected, (string) $actual);