From d68e8f60428f3901b0a3dd4af2f843ea14d45aec Mon Sep 17 00:00:00 2001 From: Luca Tumedei Date: Sat, 14 Dec 2024 11:44:07 +0100 Subject: [PATCH] fix(src) phpstan flagged issues --- composer.json | 5 +++++ src/App.php | 2 +- src/Container.php | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 21f9da5..2690f7d 100644 --- a/composer.json +++ b/composer.json @@ -20,5 +20,10 @@ }, "require-dev": { "phpunit/phpunit": "<10.0" + }, + "config": { + "platform": { + "php": "7.1" + } } } diff --git a/src/App.php b/src/App.php index ef6952a..66985d0 100644 --- a/src/App.php +++ b/src/App.php @@ -482,7 +482,7 @@ public static function callback($id, $method) */ public static function instance($id, ?array $buildArgs = [], ?array $afterBuildMethods = null) { - return static::container()->instance($id, $buildArgs, $afterBuildMethods); + return static::container()->instance($id, $buildArgs ?? [], $afterBuildMethods); } /** diff --git a/src/Container.php b/src/Container.php index 53d0e40..4fc2f75 100644 --- a/src/Container.php +++ b/src/Container.php @@ -459,6 +459,7 @@ public function register($serviceProviderClass, ...$alias) $provider->register(); } else { $provided = $provider->provides(); + // @phpstan-ignore-next-line if (!is_array($provided) || count($provided) === 0) { throw new ContainerException( "Service provider '{$serviceProviderClass}' is marked as deferred" . @@ -748,6 +749,7 @@ public function callback($id, $method) { $callbackIdPrefix = is_object($id) ? spl_object_hash($id) : $id; + // @phpstan-ignore-next-line if (!is_string($callbackIdPrefix)) { $typeOfId = gettype($id); throw new ContainerException( @@ -755,6 +757,7 @@ public function callback($id, $method) ); } + // @phpstan-ignore-next-line if (!is_string($method)) { throw new ContainerException("Callbacks second argument must be a string method name."); } @@ -878,6 +881,7 @@ public function getProvider($providerId) */ public function isBound($id) { + // @phpstan-ignore-next-line return is_string($id) && $this->resolver->isBound($id); }