@@ -55,7 +55,8 @@ public function process(File $phpcsFile, $stackPtr): void
5555 }
5656
5757 $ comma = $ phpcsFile ->findNext (T_COMMA , $ from + 1 , $ to );
58- if (false === $ comma
58+ if (
59+ false === $ comma
5960 || !$ phpcsFile ->findNext (Tokens::$ emptyTokens , $ comma + 1 , $ to , true )
6061 ) {
6162 $ fix = $ phpcsFile ->addFixableError (
@@ -159,7 +160,8 @@ public function process(File $phpcsFile, $stackPtr): void
159160 $ from = $ stackPtr ;
160161 } else {
161162 $ from = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ prev + 1 , null , true );
162- if (T_STRING === $ tokens [$ from ]['code ' ]
163+ if (
164+ T_STRING === $ tokens [$ from ]['code ' ]
163165 && in_array (strtolower ($ tokens [$ from ]['content ' ]), ['const ' , 'function ' ], true )
164166 ) {
165167 $ from = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ from + 1 , null , true );
@@ -192,7 +194,8 @@ private function removeUse(File $phpcsFile, int $from, int $to): void
192194 $ phpcsFile ->fixer ->beginChangeset ();
193195
194196 // Remote whitespaces before in the same line
195- if (T_WHITESPACE === $ tokens [$ from - 1 ]['code ' ]
197+ if (
198+ T_WHITESPACE === $ tokens [$ from - 1 ]['code ' ]
196199 && $ tokens [$ from - 1 ]['line ' ] === $ tokens [$ from ]['line ' ]
197200 && $ tokens [$ from - 2 ]['line ' ] !== $ tokens [$ from ]['line ' ]
198201 ) {
@@ -243,7 +246,8 @@ private function isClassUsed(File $phpcsFile, int $usePtr, int $classPtr): bool
243246
244247 $ type = 'class ' ;
245248 $ next = $ phpcsFile ->findNext (Tokens::$ emptyTokens , $ usePtr + 1 , null , true );
246- if (T_STRING === $ tokens [$ next ]['code ' ]
249+ if (
250+ T_STRING === $ tokens [$ next ]['code ' ]
247251 && in_array (strtolower ($ tokens [$ next ]['content ' ]), ['const ' , 'function ' ], true )
248252 ) {
249253 $ type = strtolower ($ tokens [$ next ]['content ' ]);
@@ -309,7 +313,8 @@ private function isClassUsed(File $phpcsFile, int $usePtr, int $classPtr): bool
309313
310314 $ match = null ;
311315
312- if (($ isStringToken
316+ if (
317+ ($ isStringToken
313318 && (('const ' !== $ type && strtolower ($ tokens [$ classUsed ]['content ' ]) === $ searchName )
314319 || ('const ' === $ type && $ tokens [$ classUsed ]['content ' ] === $ searchName )))
315320 || ('class ' === $ type
@@ -346,7 +351,8 @@ private function isClassUsed(File $phpcsFile, int $usePtr, int $classPtr): bool
346351 return true ;
347352 }
348353 } elseif (T_DOC_COMMENT_STRING === $ tokens [$ classUsed ]['code ' ]) {
349- if (T_DOC_COMMENT_TAG === $ tokens [$ beforeUsage ]['code ' ]
354+ if (
355+ T_DOC_COMMENT_TAG === $ tokens [$ beforeUsage ]['code ' ]
350356 && in_array ($ tokens [$ beforeUsage ]['content ' ], SniffHelper::TAGS_WITH_TYPE , true )
351357 ) {
352358 return true ;
@@ -406,19 +412,23 @@ private function determineType(File $phpcsFile, int $beforePtr, int $ptr): ?stri
406412
407413 $ beforeCode = $ tokens [$ beforePtr ]['code ' ];
408414
409- if (in_array (
410- $ beforeCode ,
411- [T_NS_SEPARATOR , T_OBJECT_OPERATOR , T_DOUBLE_COLON , T_FUNCTION , T_CONST , T_AS , T_INSTEADOF ],
412- true
413- )) {
415+ if (
416+ in_array (
417+ $ beforeCode ,
418+ [T_NS_SEPARATOR , T_OBJECT_OPERATOR , T_DOUBLE_COLON , T_FUNCTION , T_CONST , T_AS , T_INSTEADOF ],
419+ true
420+ )
421+ ) {
414422 return null ;
415423 }
416424
417- if (in_array (
418- $ beforeCode ,
419- [T_NEW , T_NULLABLE , T_EXTENDS , T_IMPLEMENTS , T_INSTANCEOF ],
420- true
421- )) {
425+ if (
426+ in_array (
427+ $ beforeCode ,
428+ [T_NEW , T_NULLABLE , T_EXTENDS , T_IMPLEMENTS , T_INSTANCEOF ],
429+ true
430+ )
431+ ) {
422432 return 'class ' ;
423433 }
424434
@@ -459,17 +469,20 @@ private function determineType(File $phpcsFile, int $beforePtr, int $ptr): ?stri
459469 return 'function ' ;
460470 }
461471
462- if (in_array (
463- $ afterCode ,
464- [T_DOUBLE_COLON , T_VARIABLE , T_ELLIPSIS , T_NS_SEPARATOR , T_OPEN_CURLY_BRACKET ],
465- true
466- )) {
472+ if (
473+ in_array (
474+ $ afterCode ,
475+ [T_DOUBLE_COLON , T_VARIABLE , T_ELLIPSIS , T_NS_SEPARATOR , T_OPEN_CURLY_BRACKET ],
476+ true
477+ )
478+ ) {
467479 return 'class ' ;
468480 }
469481
470482 if (T_COLON === $ beforeCode ) {
471483 $ prev = $ phpcsFile ->findPrevious (Tokens::$ emptyTokens , $ beforePtr - 1 , null , true );
472- if (false !== $ prev
484+ if (
485+ false !== $ prev
473486 && T_CLOSE_PARENTHESIS === $ tokens [$ prev ]['code ' ]
474487 && isset ($ tokens [$ prev ]['parenthesis_owner ' ])
475488 && T_FUNCTION === $ tokens [$ tokens [$ prev ]['parenthesis_owner ' ]]['code ' ]
0 commit comments