@@ -318,6 +318,18 @@ function resolveDocMixins($class)
318
318
->flatMap (fn ($ mixin ) => [$ mixin , ...resolveDocMixins ($ mixin )]);
319
319
}
320
320
321
+ /**
322
+ * Resolve the classes referenced methods in the @methods docblocks.
323
+ *
324
+ * @param \ReflectionMethodDecorator $method
325
+ * @return \Illuminate\Support\Collection<int, string>
326
+ */
327
+ function resolveDocParameters ($ method )
328
+ {
329
+ return resolveDocTags ($ method ->getDocComment () ?: '' , '@param ' )
330
+ ->map (fn ($ tag ) => Str::squish ($ tag ));
331
+ }
332
+
321
333
/**
322
334
* Determine if the method is magic.
323
335
*
@@ -428,7 +440,7 @@ function normaliseDetails($method)
428
440
{
429
441
return is_string ($ method ) ? $ method : [
430
442
'name ' => $ method ->getName (),
431
- 'parameters ' => collect ($ method-> getParameters () )
443
+ 'parameters ' => resolveParameters ($ method )
432
444
->map (fn ($ parameter ) => [
433
445
'name ' => '$ ' .$ parameter ->getName (),
434
446
'optional ' => $ parameter ->isOptional () && ! $ parameter ->isVariadic (),
@@ -442,6 +454,21 @@ function normaliseDetails($method)
442
454
];
443
455
}
444
456
457
+ /**
458
+ * Resolve the parameters for the method.
459
+ *
460
+ * @param \ReflectionMethodDecorator $method
461
+ * @return \Illuminate\Support\Collection<int, \ReflectionParameter|\DynamicParameter>
462
+ */
463
+ function resolveParameters ($ method )
464
+ {
465
+ $ dynamicParameters = resolveDocParameters ($ method )
466
+ ->skip ($ method ->getNumberOfParameters ())
467
+ ->mapInto (DynamicParameter::class);
468
+
469
+ return collect ($ method ->getParameters ())->merge ($ dynamicParameters );
470
+ }
471
+
445
472
/**
446
473
* Resolve the default value for the parameter.
447
474
*
@@ -505,3 +532,57 @@ public function sourceClass()
505
532
return new ReflectionClass ($ this ->sourceClass );
506
533
}
507
534
}
535
+
536
+ class DynamicParameter
537
+ {
538
+ /**
539
+ * @param string $definition
540
+ */
541
+ public function __construct (private $ definition )
542
+ {
543
+ //
544
+ }
545
+
546
+ /**
547
+ * @return string
548
+ */
549
+ public function getName ()
550
+ {
551
+ return Str::of ($ this ->definition )
552
+ ->after ('$ ' )
553
+ ->before (' ' )
554
+ ->toString ();
555
+ }
556
+
557
+ /**
558
+ * @return bool
559
+ */
560
+ public function isOptional ()
561
+ {
562
+ return true ;
563
+ }
564
+
565
+ /**
566
+ * @return bool
567
+ */
568
+ public function isVariadic ()
569
+ {
570
+ return Str::contains ($ this ->definition , " ... \${$ this ->getName ()}" );
571
+ }
572
+
573
+ /**
574
+ * @return bool
575
+ */
576
+ public function isDefaultValueAvailable ()
577
+ {
578
+ return true ;
579
+ }
580
+
581
+ /**
582
+ * @return null
583
+ */
584
+ public function getDefaultValue ()
585
+ {
586
+ return null ;
587
+ }
588
+ }
0 commit comments