Skip to content

Commit

Permalink
fix(src) phpstan flagged issues
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Dec 14, 2024
1 parent 525e4d6 commit d68e8f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@
},
"require-dev": {
"phpunit/phpunit": "<10.0"
},
"config": {
"platform": {
"php": "7.1"
}
}
}
2 changes: 1 addition & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -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" .
Expand Down Expand Up @@ -748,13 +749,15 @@ 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(
"Callbacks can only be built on ids, class names or objects; '{$typeOfId}' is neither."
);
}

// @phpstan-ignore-next-line
if (!is_string($method)) {
throw new ContainerException("Callbacks second argument must be a string method name.");
}
Expand Down Expand Up @@ -878,6 +881,7 @@ public function getProvider($providerId)
*/
public function isBound($id)
{
// @phpstan-ignore-next-line
return is_string($id) && $this->resolver->isBound($id);
}

Expand Down

0 comments on commit d68e8f6

Please sign in to comment.