From 2998eec89625d10bd7ef619894d59b80e06dd254 Mon Sep 17 00:00:00 2001 From: nkl-kst <24235974+nkl-kst@users.noreply.github.com> Date: Wed, 17 May 2023 23:14:20 +0200 Subject: [PATCH] Fixed PHPStan level 8 errors for DependencyContainer --- src/Dependency/DependencyContainer.php | 7 ++++--- src/Exception/ClientInstantiationException.php | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 src/Exception/ClientInstantiationException.php diff --git a/src/Dependency/DependencyContainer.php b/src/Dependency/DependencyContainer.php index 44f2a28..f3f04bb 100644 --- a/src/Dependency/DependencyContainer.php +++ b/src/Dependency/DependencyContainer.php @@ -11,6 +11,7 @@ use NklKst\TheSportsDb\Client\Endpoint\LookupEndpoint; use NklKst\TheSportsDb\Client\Endpoint\ScheduleEndpoint; use NklKst\TheSportsDb\Client\Endpoint\SearchEndpoint; +use NklKst\TheSportsDb\Exception\ClientInstantiationException; use NklKst\TheSportsDb\Request\RequestBuilder; use NklKst\TheSportsDb\Serializer\CountrySerializer; use NklKst\TheSportsDb\Serializer\EquipmentSerializer; @@ -72,7 +73,7 @@ class DependencyContainer TimelineSerializer::class, ]; - private static ?ContainerBuilder $builder = null; + private static ContainerBuilder $builder; private static function load(): void { @@ -127,7 +128,7 @@ private static function compile(): void self::$builder->compile(); } - public static function getClient(): ?Client + public static function getClient(): Client { // Load dependency container self::load(); @@ -139,6 +140,6 @@ public static function getClient(): ?Client } // Something went wrong... - return null; + throw new ClientInstantiationException(); } } diff --git a/src/Exception/ClientInstantiationException.php b/src/Exception/ClientInstantiationException.php new file mode 100644 index 0000000..60bcced --- /dev/null +++ b/src/Exception/ClientInstantiationException.php @@ -0,0 +1,7 @@ +