@@ -482,7 +482,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
482
482
$ commentLines = [];
483
483
if ($ tokens [($ tag + 2 )]['code ' ] === T_DOC_COMMENT_STRING ) {
484
484
$ matches = [];
485
- preg_match ('/([^$&] *)(?:((?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/ ' , $ tokens [($ tag + 2 )]['content ' ], $ matches );
485
+ preg_match ('/((?:(?![$.]|&(?=\$)).) *)(?:((?:\.\.\.)? (?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/ ' , $ tokens [($ tag + 2 )]['content ' ], $ matches );
486
486
487
487
$ typeLen = strlen ($ matches [1 ]);
488
488
$ type = trim ($ matches [1 ]);
@@ -618,7 +618,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
618
618
$ variableArguments = true ;
619
619
}
620
620
621
- if ($ typeLen === 0 ) {
621
+ if ($ typeLen === 0 && $ variableArguments === false ) {
622
622
$ error = 'Missing parameter type ' ;
623
623
// If there is just one word as comment at the end of the line
624
624
// then this is probably the data type. Move it before the
@@ -677,8 +677,11 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
677
677
while (isset ($ realParams [($ checkPos )]) === true ) {
678
678
$ realName = $ realParams [$ checkPos ]['name ' ];
679
679
680
- if ($ realName === $ param ['var ' ] || ($ realParams [$ checkPos ]['pass_by_reference ' ] === true
680
+ if ($ realName === $ param ['var ' ]
681
+ || ($ realParams [$ checkPos ]['pass_by_reference ' ] === true
681
682
&& ('& ' .$ realName ) === $ param ['var ' ])
683
+ || ($ realParams [$ checkPos ]['variable_length ' ] === true
684
+ && ('... ' .$ realName ) === $ param ['var ' ])
682
685
) {
683
686
$ matched = true ;
684
687
break ;
@@ -923,7 +926,7 @@ public static function suggestType($type)
923
926
// Also allow some more characters for special type hints supported by
924
927
// PHPStan:
925
928
// https://phpstan.org/writing-php-code/phpdoc-types#basic-types .
926
- $ type = preg_replace ('/[^a-zA-Z0-9_ \\\[\]\-<> ,"\{\}\? \':\*]/ ' , '' , $ type );
929
+ $ type = preg_replace ('/[^a-zA-Z0-9_ \\\[\]\-<> ,"\{\}\? \':\*\|\& ]/ ' , '' , $ type );
927
930
928
931
return $ type ;
929
932
0 commit comments