@@ -367,6 +367,37 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
367367 }
368368
369369 foreach ($ params as $ pos => $ param ) {
370+ // Make sure the param name is correct.
371+ if (isset ($ realParams [$ pos ]) === true ) {
372+ $ realName = $ realParams [$ pos ]['name ' ];
373+ if ($ realName !== $ param ['var ' ]) {
374+ $ index = array_search ($ param ['var ' ], array_column ($ realParams , 'name ' ));
375+ if ($ index === false ) {
376+ $ code = 'ParamNameNoMatch ' ;
377+ $ data = [
378+ $ param ['var ' ],
379+ $ realName ,
380+ ];
381+
382+ $ error = 'Doc comment for parameter %s does not match ' ;
383+ if (strtolower ($ param ['var ' ]) === strtolower ($ realName )) {
384+ $ error .= 'case of ' ;
385+ $ code = 'ParamNameNoCaseMatch ' ;
386+ }
387+
388+ $ error .= 'actual variable name %s ' ;
389+
390+ $ phpcsFile ->addError ($ error , $ param ['tag ' ], $ code , $ data );
391+ } else {
392+ $ pos = $ index ;
393+ }
394+ }
395+ } else if (substr ($ param ['var ' ], -4 ) !== ',... ' ) {
396+ // We must have an extra parameter comment.
397+ $ error = 'Superfluous parameter comment ' ;
398+ $ phpcsFile ->addError ($ error , $ param ['tag ' ], 'ExtraParamComment ' );
399+ }//end if
400+
370401 // If the type is empty, the whole line is empty.
371402 if ($ param ['type ' ] === '' ) {
372403 continue ;
@@ -515,32 +546,6 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
515546 // Check number of spaces after the type.
516547 $ this ->checkSpacingAfterParamType ($ phpcsFile , $ param , $ maxType );
517548
518- // Make sure the param name is correct.
519- if (isset ($ realParams [$ pos ]) === true ) {
520- $ realName = $ realParams [$ pos ]['name ' ];
521- if ($ realName !== $ param ['var ' ]) {
522- $ code = 'ParamNameNoMatch ' ;
523- $ data = [
524- $ param ['var ' ],
525- $ realName ,
526- ];
527-
528- $ error = 'Doc comment for parameter %s does not match ' ;
529- if (strtolower ($ param ['var ' ]) === strtolower ($ realName )) {
530- $ error .= 'case of ' ;
531- $ code = 'ParamNameNoCaseMatch ' ;
532- }
533-
534- $ error .= 'actual variable name %s ' ;
535-
536- $ phpcsFile ->addError ($ error , $ param ['tag ' ], $ code , $ data );
537- }
538- } else if (substr ($ param ['var ' ], -4 ) !== ',... ' ) {
539- // We must have an extra parameter comment.
540- $ error = 'Superfluous parameter comment ' ;
541- $ phpcsFile ->addError ($ error , $ param ['tag ' ], 'ExtraParamComment ' );
542- }//end if
543-
544549 if ($ param ['comment ' ] === '' ) {
545550 continue ;
546551 }
0 commit comments