Skip to content

Commit

Permalink
Mark nullable parameters as such
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Jan 9, 2020
1 parent 091cbe9 commit b01ccf4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CurrencyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CurrencyConversionException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
8 changes: 4 additions & 4 deletions src/Money.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b01ccf4

Please sign in to comment.