1313
1414class LaravelRequestDocs
1515{
16- public function __construct (private RoutePath $ routePath )
16+ private RoutePath $ routePath ;
17+
18+ public function __construct (RoutePath $ routePath )
1719 {
20+ $ this ->routePath = $ routePath ;
1821 }
1922
2023 /**
@@ -29,7 +32,7 @@ public function getDocs(
2932 bool $ showPut ,
3033 bool $ showPatch ,
3134 bool $ showDelete ,
32- bool $ showHead,
35+ bool $ showHead
3336 ): Collection {
3437 $ filteredMethods = array_filter ([
3538 Request::METHOD_GET => $ showGet ,
@@ -183,10 +186,13 @@ public function getControllersInfo(array $onlyMethods): Collection
183186 $ pathParameters [$ k ] = [$ v ];
184187 }
185188
189+ /** @var string[] $middlewares */
190+ $ middlewares = $ route ->middleware ();
191+
186192 $ doc = new Doc (
187193 $ route ->uri ,
188194 $ routeMethods ,
189- config ('request-docs.hide_meta_data ' ) ? [] : $ route -> middleware () ,
195+ config ('request-docs.hide_meta_data ' ) ? [] : $ middlewares ,
190196 config ('request-docs.hide_meta_data ' ) ? '' : $ controllerName ,
191197 config ('request-docs.hide_meta_data ' ) ? '' : $ controllerFullPath ,
192198 config ('request-docs.hide_meta_data ' ) ? '' : $ method ,
@@ -253,7 +259,7 @@ public function appendRequestRules(Collection $docs): Collection
253259
254260 try {
255261 $ requestObject = $ reflectionClass ->newInstance ();
256- } catch (Throwable ) {
262+ } catch (Throwable $ ex ) {
257263 $ requestObject = $ reflectionClass ->newInstanceWithoutConstructor ();
258264 }
259265
@@ -265,7 +271,7 @@ public function appendRequestRules(Collection $docs): Collection
265271 try {
266272 $ doc ->mergeRules ($ this ->flattenRules ($ requestObject ->$ requestMethod ()));
267273 $ requestReflectionMethod = new ReflectionMethod ($ requestObject , $ requestMethod );
268- } catch (Throwable ) {
274+ } catch (Throwable $ ex ) {
269275 $ doc ->mergeRules ($ this ->rulesByRegex ($ requestClassName , $ requestMethod ));
270276 $ requestReflectionMethod = new ReflectionMethod ($ requestClassName , $ requestMethod );
271277 }
@@ -278,7 +284,7 @@ public function appendRequestRules(Collection $docs): Collection
278284 $ lrdDocComments [] = $ requestMethodLrdComment ;
279285 $ doc ->mergeRules ($ requestMethodDocRules );
280286 }
281- } catch (Throwable ) {
287+ } catch (Throwable $ ex ) {
282288 // Do nothing.
283289 }
284290 }
@@ -335,15 +341,15 @@ public function flattenRules(array $mixedRules): array
335341
336342 foreach ($ mixedRules as $ attribute => $ rule ) {
337343 if (is_object ($ rule )) {
338- $ rules [$ attribute ][] = $ rule::class ;
344+ $ rules [$ attribute ][] = get_class ( $ rule) ;
339345 continue ;
340346 }
341347
342348 if (is_array ($ rule )) {
343349 $ rulesStrs = [];
344350
345351 foreach ($ rule as $ ruleItem ) {
346- $ rulesStrs [] = is_object ($ ruleItem ) ? $ ruleItem::class : $ ruleItem ;
352+ $ rulesStrs [] = is_object ($ ruleItem ) ? get_class ( $ ruleItem) : $ ruleItem ;
347353 }
348354
349355 $ rules [$ attribute ][] = implode ("| " , $ rulesStrs );
0 commit comments