Skip to content

Commit

Permalink
Fix PHPStan errors reported on PHP 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Feb 4, 2025
1 parent d3e6f90 commit 201b465
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Glpi/Api/HL/RoutePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ private function hydrate(): void
if (!$is_hydrated) {
[$controller, $method] = explode('::', $this->key);
try {
if (!\is_a($controller, AbstractController::class, true)) {
throw new \Exception('Invalid controller');
}
$this->controller = new ReflectionClass($controller);
$this->method = $this->controller->getMethod($method);
if (!$this->method->isPublic()) {
Expand Down
6 changes: 5 additions & 1 deletion src/Glpi/Console/CommandLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,13 @@ private function getCommandFromFile(SplFileInfo $file, $basedir, array $prefixes
// Needed as a file located in root source dir of Glpi can be either namespaced either not.
continue;
}
if (!is_a($classname_to_check, Command::class, true)) {
// Not a console command.
continue;
}

$reflectionClass = new ReflectionClass($classname_to_check);
if ($reflectionClass->isInstantiable() && $reflectionClass->isSubclassOf(Command::class)) {
if ($reflectionClass->isInstantiable()) {
return new $classname_to_check();
}
}
Expand Down

0 comments on commit 201b465

Please sign in to comment.