@@ -580,18 +580,19 @@ public function getVariableName(): string {
580
580
throw new Exception ("@ $ this ->name doesn't have any value " );
581
581
}
582
582
583
+ $ matches = [];
584
+
583
585
if ($ this ->name === "param " ) {
584
- $ pos = strpos ($ value , " " );
585
- if ($ pos !== false ) {
586
- $ value = substr ($ value , $ pos + 1 );
587
- }
586
+ preg_match ('/^\s*[\w\| \\\]+\s*\$(\w+).*$/ ' , $ value , $ matches );
587
+ } elseif ($ this ->name === "prefer-ref " ) {
588
+ preg_match ('/^\s*\$(\w+).*$/ ' , $ value , $ matches );
588
589
}
589
590
590
- if ($ value [ 0 ] !== ' $ ' ) {
591
- throw new Exception ("@ $ this ->name doesn't contain variable name " );
591
+ if (isset ( $ matches [ 1 ]) === false ) {
592
+ throw new Exception ("@ $ this ->name doesn't contain variable name or has an invalid format \" $ value \" " );
592
593
}
593
594
594
- return substr ( $ value , 1 ) ;
595
+ return $ matches [ 1 ] ;
595
596
}
596
597
}
597
598
@@ -673,8 +674,8 @@ function parseFunctionLike(
673
674
$ type = $ param ->type ? Type::fromNode ($ param ->type ) : null ;
674
675
if ($ type === null && !isset ($ docParamTypes [$ varName ]) && !$ hasParameterWarning ) {
675
676
$ hasParameterWarning = true ;
676
- //throw new Exception("Missing argument type for function $name()");
677
- echo "Warning: Missing argument type for function $ name() \n" ;
677
+ //throw new Exception("Missing parameter type for function $name()");
678
+ echo "Warning: Missing parameter type for function $ name() \n" ;
678
679
}
679
680
680
681
if ($ param ->default instanceof Expr \ConstFetch &&
@@ -1124,7 +1125,7 @@ function initPhpParser() {
1124
1125
$ optind = null ;
1125
1126
$ options = getopt ("f " , ["force-regeneration " ], $ optind );
1126
1127
$ forceRegeneration = isset ($ options ["f " ]) || isset ($ options ["force-regeneration " ]);
1127
- $ location = $ argv [$ optind + 1 ] ?? ". " ;
1128
+ $ location = $ argv [$ optind ] ?? ". " ;
1128
1129
1129
1130
if (is_file ($ location )) {
1130
1131
// Generate single file.
0 commit comments