From d93252483c5986c8cbb839cba29e951121389f44 Mon Sep 17 00:00:00 2001 From: Corentin H <1763364+viki53@users.noreply.github.com> Date: Tue, 9 Mar 2021 18:20:17 +0100 Subject: [PATCH] Fix PHP8 deprecation in `Generator::getFormRules` See mtrajano/laravel-swagger#60 for more details --- src/Generator.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Generator.php b/src/Generator.php index 804bad3..41ddfda 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -190,13 +190,9 @@ protected function getFormRules(): array $parameters = $action_instance->getParameters(); foreach ($parameters as $parameter) { - $class = $parameter->getClass(); - - if (!$class) { - continue; - } - - $class_name = $class->getName(); + $class_name = $name = $parameter->getType() && !$parameter->getType()->isBuiltin() + ? new \ReflectionClass($parameter->getType()->getName()) + : null; if (is_subclass_of($class_name, FormRequest::class)) { return (new $class_name)->rules();