From 011927d3046de20c07aaa866e7c5315bb97cc6ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 15 Apr 2024 17:19:54 +0200 Subject: [PATCH] Make implicit nullable param to explicit --- src/Ray.php | 4 ++-- src/Settings/SettingsFactory.php | 8 ++++---- tests/TestClasses/FakeClock.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Ray.php b/src/Ray.php index c0fb9576..f0718ba6 100644 --- a/src/Ray.php +++ b/src/Ray.php @@ -107,14 +107,14 @@ class Ray /** @var Closure|null */ public static $beforeSendRequest = null; - public static function create(Client $client = null, string $uuid = null): self + public static function create(?Client $client = null, string $uuid = null): self { $settings = SettingsFactory::createFromConfigFile(); return new static($settings, $client, $uuid); } - public function __construct(Settings $settings, Client $client = null, string $uuid = null) + public function __construct(Settings $settings, ?Client $client = null, ?string $uuid = null) { $this->settings = $settings; diff --git a/src/Settings/SettingsFactory.php b/src/Settings/SettingsFactory.php index 7c64446a..e9c12e0b 100644 --- a/src/Settings/SettingsFactory.php +++ b/src/Settings/SettingsFactory.php @@ -11,7 +11,7 @@ public static function createFromArray(array $settings = []): Settings return new Settings($settings); } - public static function createFromConfigFile(string $configDirectory = null): Settings + public static function createFromConfigFile(?string $configDirectory = null): Settings { $settingValues = (new static())->getSettingsFromConfigFile($configDirectory); @@ -24,7 +24,7 @@ public static function createFromConfigFile(string $configDirectory = null): Set return $settings; } - public function getSettingsFromConfigFile(string $configDirectory = null): array + public function getSettingsFromConfigFile(?string $configDirectory = null): array { $configFilePath = $this->searchConfigFiles($configDirectory); @@ -37,7 +37,7 @@ public function getSettingsFromConfigFile(string $configDirectory = null): array return $options ?? []; } - protected function searchConfigFiles(string $configDirectory = null): string + protected function searchConfigFiles(?string $configDirectory = null): string { if (! isset(self::$cache[$configDirectory])) { self::$cache[$configDirectory] = $this->searchConfigFilesOnDisk($configDirectory); @@ -46,7 +46,7 @@ protected function searchConfigFiles(string $configDirectory = null): string return self::$cache[$configDirectory]; } - protected function searchConfigFilesOnDisk(string $configDirectory = null): string + protected function searchConfigFilesOnDisk(?string $configDirectory = null): string { $configNames = [ 'ray.php', diff --git a/tests/TestClasses/FakeClock.php b/tests/TestClasses/FakeClock.php index d73b61c1..f1ae2448 100644 --- a/tests/TestClasses/FakeClock.php +++ b/tests/TestClasses/FakeClock.php @@ -10,7 +10,7 @@ class FakeClock implements Clock /** @var DateTimeImmutable|null */ protected $fixedNow; - public function __construct(DateTimeImmutable $now = null) + public function __construct(?DateTimeImmutable $now = null) { $this->fixedNow = $now; } @@ -20,7 +20,7 @@ public function now(): DateTimeImmutable return $this->fixedNow ?? new DateTimeImmutable(); } - public function freeze(DateTimeImmutable $now = null): void + public function freeze(?DateTimeImmutable $now = null): void { $this->fixedNow = $now ?? new DateTimeImmutable(); }