@@ -576,8 +576,19 @@ public function getValue(): string {
576
576
577
577
public function getVariableName (): string {
578
578
$ value = $ this ->getValue ();
579
- if ($ value === null || strlen ($ value ) === 0 || $ value [0 ] !== '$ ' ) {
580
- throw new Exception ("@ $ this ->name not followed by variable name " );
579
+ if ($ value === null || strlen ($ value ) === 0 ) {
580
+ throw new Exception ("@ $ this ->name doesn't have any value " );
581
+ }
582
+
583
+ if ($ this ->name === "param " ) {
584
+ $ pos = strpos ($ value , " " );
585
+ if ($ pos !== false ) {
586
+ $ value = substr ($ value , $ pos + 1 );
587
+ }
588
+ }
589
+
590
+ if ($ value [0 ] !== '$ ' ) {
591
+ throw new Exception ("@ $ this ->name doesn't contain variable name " );
581
592
}
582
593
583
594
return substr ($ value , 1 );
@@ -610,6 +621,7 @@ function parseFunctionLike(
610
621
$ alias = null ;
611
622
$ isDeprecated = false ;
612
623
$ haveDocReturnType = false ;
624
+ $ docParamTypes = [];
613
625
614
626
if ($ comment ) {
615
627
$ tags = parseDocComment ($ comment );
@@ -631,13 +643,16 @@ function parseFunctionLike(
631
643
$ isDeprecated = true ;
632
644
} else if ($ tag ->name === 'return ' ) {
633
645
$ haveDocReturnType = true ;
646
+ } else if ($ tag ->name === 'param ' ) {
647
+ $ docParamTypes [$ tag ->getVariableName ()] = true ;
634
648
}
635
649
}
636
650
}
637
651
638
652
$ args = [];
639
653
$ numRequiredArgs = 0 ;
640
654
$ foundVariadic = false ;
655
+ $ hasParameterWarning = false ;
641
656
foreach ($ func ->getParams () as $ i => $ param ) {
642
657
$ varName = $ param ->var ->name ;
643
658
$ preferRef = !empty ($ paramMeta [$ varName ]['preferRef ' ]);
@@ -656,6 +671,12 @@ function parseFunctionLike(
656
671
}
657
672
658
673
$ type = $ param ->type ? Type::fromNode ($ param ->type ) : null ;
674
+ if ($ type === null && !isset ($ docParamTypes [$ varName ]) && !$ hasParameterWarning ) {
675
+ $ hasParameterWarning = true ;
676
+ //throw new Exception("Missing argument type for function $name()");
677
+ echo "Warning: Missing argument type for function $ name() \n" ;
678
+ }
679
+
659
680
if ($ param ->default instanceof Expr \ConstFetch &&
660
681
$ param ->default ->name ->toLowerString () === "null " &&
661
682
$ type && !$ type ->isNullable ()
0 commit comments