Skip to content

Commit

Permalink
Increased level PHPStan up to 9, fixed PHPStan errors, removed useles…
Browse files Browse the repository at this point in the history
…s checks in Container
  • Loading branch information
renakdup committed Nov 29, 2023
1 parent df11738 commit 6671de7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 6
level: 9
phpVersion: 70400 # PHP 7.4
parallel:
jobSize: 20
Expand Down
9 changes: 4 additions & 5 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,9 @@ protected function resolve( string $id ) {
return $service( $this );
} elseif ( is_string( $service ) && class_exists( $service ) ) {
return $this->resolve_object( $service );
} elseif ( is_scalar( $service ) || is_array( $service ) || $service === null ) {
return $service;
} elseif ( is_object( $service ) ) {
return $service;
}

throw new ContainerNotFoundException( "Service '{$service}' not found in the Container." );
return $service;
} else {
if ( is_string( $id ) && class_exists( $id ) ) {
return $this->resolve_object( $id );
Expand All @@ -133,6 +129,9 @@ protected function resolve( string $id ) {
}
}

/**
* @param class-string $service
*/
protected function resolve_object( string $service ): object {
$reflected_class = new ReflectionClass( $service );
$constructor = $reflected_class->getConstructor();
Expand Down

0 comments on commit 6671de7

Please sign in to comment.