@@ -128,7 +128,7 @@ protected function generateSecurityDefinitions()
128128
129129 protected function generatePath ()
130130 {
131- $ actionInstance = is_string ( $ this ->route -> action ()) ? $ this -> getActionClassInstance ($ this -> route -> action ()) : null ;
131+ $ actionInstance = $ this ->getActionClassInstance () ;
132132 $ docBlock = $ actionInstance ? ($ actionInstance ->getDocComment () ?: '' ) : '' ;
133133
134134 [$ isDeprecated , $ summary , $ description ] = $ this ->parseActionDocBlock ($ docBlock );
@@ -179,21 +179,31 @@ protected function addActionScopes()
179179 }
180180 }
181181
182- protected function getFormRules ()
182+ protected function getFormRules () : array
183183 {
184- if (!is_string ($ this ->route ->action ())) {
185- return false ;
184+ $ action_instance = $ this ->getActionClassInstance ();
185+
186+ if (!$ action_instance ) {
187+ return [];
186188 }
187189
188- $ parameters = $ this -> getActionClassInstance ( $ this -> route -> action ()) ->getParameters ();
190+ $ parameters = $ action_instance ->getParameters ();
189191
190192 foreach ($ parameters as $ parameter ) {
191- $ class = ( string ) $ parameter ->getName ();
193+ $ class = $ parameter ->getClass ();
192194
193- if (is_subclass_of ($ class , FormRequest::class)) {
194- return (new $ class )->rules ();
195+ if (!$ class ) {
196+ continue ;
197+ }
198+
199+ $ class_name = $ class ->getName ();
200+
201+ if (is_subclass_of ($ class_name , FormRequest::class)) {
202+ return (new $ class_name )->rules ();
195203 }
196204 }
205+
206+ return [];
197207 }
198208
199209 protected function getParameterGenerator ($ rules )
@@ -208,9 +218,13 @@ protected function getParameterGenerator($rules)
208218 }
209219 }
210220
211- private function getActionClassInstance (string $ action )
221+ private function getActionClassInstance () : ? ReflectionMethod
212222 {
213- [$ class , $ method ] = Str::parseCallback ($ action );
223+ [$ class , $ method ] = Str::parseCallback ($ this ->route ->action ());
224+
225+ if (!$ class || !$ method ) {
226+ return null ;
227+ }
214228
215229 return new ReflectionMethod ($ class , $ method );
216230 }
0 commit comments