@@ -217,7 +217,7 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
217
217
218
218
if ($ tokens [($ tag + 2 )]['code ' ] === T_DOC_COMMENT_STRING ) {
219
219
$ matches = [];
220
- preg_match ('/([^$&.]+ )(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/ ' , $ tokens [($ tag + 2 )]['content ' ], $ matches );
220
+ preg_match ('/((?:(?![$.]|&(?=\$)).)* )(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/ ' , $ tokens [($ tag + 2 )]['content ' ], $ matches );
221
221
222
222
if (empty ($ matches ) === false ) {
223
223
$ typeLen = strlen ($ matches [1 ]);
@@ -297,43 +297,45 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
297
297
298
298
$ foundParams [] = $ param ['var ' ];
299
299
300
- // Check number of spaces after the type.
301
- $ spaces = ($ maxType - strlen ($ param ['type ' ]) + 1 );
302
- if ($ param ['type_space ' ] !== $ spaces ) {
303
- $ error = 'Expected %s spaces after parameter type; %s found ' ;
304
- $ data = [
305
- $ spaces ,
306
- $ param ['type_space ' ],
307
- ];
300
+ if (trim ($ param ['type ' ]) !== '' ) {
301
+ // Check number of spaces after the type.
302
+ $ spaces = ($ maxType - strlen ($ param ['type ' ]) + 1 );
303
+ if ($ param ['type_space ' ] !== $ spaces ) {
304
+ $ error = 'Expected %s spaces after parameter type; %s found ' ;
305
+ $ data = [
306
+ $ spaces ,
307
+ $ param ['type_space ' ],
308
+ ];
308
309
309
- $ fix = $ phpcsFile ->addFixableError ($ error , $ param ['tag ' ], 'SpacingAfterParamType ' , $ data );
310
- if ($ fix === true ) {
311
- $ commentToken = ($ param ['tag ' ] + 2 );
310
+ $ fix = $ phpcsFile ->addFixableError ($ error , $ param ['tag ' ], 'SpacingAfterParamType ' , $ data );
311
+ if ($ fix === true ) {
312
+ $ commentToken = ($ param ['tag ' ] + 2 );
312
313
313
- $ content = $ param ['type ' ];
314
- $ content .= str_repeat (' ' , $ spaces );
315
- $ content .= $ param ['var ' ];
316
- $ content .= str_repeat (' ' , $ param ['var_space ' ]);
314
+ $ content = $ param ['type ' ];
315
+ $ content .= str_repeat (' ' , $ spaces );
316
+ $ content .= $ param ['var ' ];
317
+ $ content .= str_repeat (' ' , $ param ['var_space ' ]);
317
318
318
- $ wrapLength = ($ tokens [$ commentToken ]['length ' ] - $ param ['type_space ' ] - $ param ['var_space ' ] - strlen ($ param ['type ' ]) - strlen ($ param ['var ' ]));
319
+ $ wrapLength = ($ tokens [$ commentToken ]['length ' ] - $ param ['type_space ' ] - $ param ['var_space ' ] - strlen ($ param ['type ' ]) - strlen ($ param ['var ' ]));
319
320
320
- $ star = $ phpcsFile ->findPrevious (T_DOC_COMMENT_STAR , $ param ['tag ' ]);
321
- $ spaceLength = (strlen ($ content ) + $ tokens [($ commentToken - 1 )]['length ' ] + $ tokens [($ commentToken - 2 )]['length ' ]);
321
+ $ star = $ phpcsFile ->findPrevious (T_DOC_COMMENT_STAR , $ param ['tag ' ]);
322
+ $ spaceLength = (strlen ($ content ) + $ tokens [($ commentToken - 1 )]['length ' ] + $ tokens [($ commentToken - 2 )]['length ' ]);
322
323
323
- $ padding = str_repeat (' ' , ($ tokens [$ star ]['column ' ] - 1 ));
324
- $ padding .= '* ' ;
325
- $ padding .= str_repeat (' ' , $ spaceLength );
324
+ $ padding = str_repeat (' ' , ($ tokens [$ star ]['column ' ] - 1 ));
325
+ $ padding .= '* ' ;
326
+ $ padding .= str_repeat (' ' , $ spaceLength );
326
327
327
- $ content .= wordwrap (
328
- $ param ['comment ' ],
329
- $ wrapLength ,
330
- $ phpcsFile ->eolChar .$ padding
331
- );
328
+ $ content .= wordwrap (
329
+ $ param ['comment ' ],
330
+ $ wrapLength ,
331
+ $ phpcsFile ->eolChar .$ padding
332
+ );
332
333
333
- $ phpcsFile ->fixer ->replaceToken ($ commentToken , $ content );
334
- for ($ i = ($ commentToken + 1 ); $ i <= $ param ['comment_end ' ]; $ i ++) {
335
- $ phpcsFile ->fixer ->replaceToken ($ i , '' );
336
- }
334
+ $ phpcsFile ->fixer ->replaceToken ($ commentToken , $ content );
335
+ for ($ i = ($ commentToken + 1 ); $ i <= $ param ['comment_end ' ]; $ i ++) {
336
+ $ phpcsFile ->fixer ->replaceToken ($ i , '' );
337
+ }
338
+ }//end if
337
339
}//end if
338
340
}//end if
339
341
0 commit comments