File tree 1 file changed +14
-6
lines changed
src/Standards/PSR12/Sniffs/Operators
1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public function register()
36
36
$ targets [] = T_INSTANCEOF ;
37
37
38
38
// Also register the contexts we want to specifically skip over.
39
- $ targets += $ this -> contextsToIgnore ;
39
+ $ targets[] = T_DECLARE ;
40
40
41
41
return $ targets ;
42
42
@@ -57,13 +57,21 @@ public function register()
57
57
*/
58
58
public function process (File $ phpcsFile , $ stackPtr )
59
59
{
60
- // There are certain contexts where this sniff should not apply. Skip those.
61
- $ skipTokensUntil = $ this ->getTokenToSkipUtil ($ phpcsFile , $ stackPtr );
62
- if ($ skipTokensUntil !== null ) {
63
- return $ skipTokensUntil ;
60
+ $ tokens = $ phpcsFile ->getTokens ();
61
+
62
+ // Skip over declare statements as those should be handled by different sniffs.
63
+ if ($ tokens [$ stackPtr ]['code ' ] === T_DECLARE ) {
64
+ if (isset ($ tokens [$ stackPtr ]['parenthesis_closer ' ]) === false ) {
65
+ // Parse error / live coding.
66
+ return $ phpcsFile ->numTokens ;
67
+ }
68
+
69
+ return $ tokens [$ stackPtr ]['parenthesis_closer ' ];
64
70
}
65
71
66
- $ tokens = $ phpcsFile ->getTokens ();
72
+ if ($ this ->isOperator ($ phpcsFile , $ stackPtr ) === false ) {
73
+ return ;
74
+ }
67
75
68
76
$ operator = $ tokens [$ stackPtr ]['content ' ];
69
77
You can’t perform that action at this time.
0 commit comments