Skip to content

Commit

Permalink
Silence Passing null to class_exists() deprecation warning
Browse files Browse the repository at this point in the history
Since PHP 8.1 passing null to class_exists() is deprecated.
I have re-factored SubstituteBindings::getClassName() to silence deprecation warning
  • Loading branch information
soltmar authored Oct 25, 2023
1 parent ab656aa commit c3e368f
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Middleware/SubstituteBindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,11 @@ private function signatureParameters(Route $route)
*/
private function getClassName(ReflectionParameter $parameter): ?string
{
$class = null;

if (($type = $parameter->getType()) && $type instanceof \ReflectionNamedType && !$type->isBuiltin()) {
$class = $type->getName();
return class_exists($class) ? $class : null;
}

return class_exists($class) ? $class : null;
return null;
}
}

0 comments on commit c3e368f

Please sign in to comment.