Skip to content

Commit a1eeb4f

Browse files
committed
Update child class to match changes in parent
1 parent 23147e2 commit a1eeb4f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php

+14-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function register()
3636
$targets[] = T_INSTANCEOF;
3737

3838
// Also register the contexts we want to specifically skip over.
39-
$targets += $this->contextsToIgnore;
39+
$targets[] = T_DECLARE;
4040

4141
return $targets;
4242

@@ -57,13 +57,21 @@ public function register()
5757
*/
5858
public function process(File $phpcsFile, $stackPtr)
5959
{
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'];
6470
}
6571

66-
$tokens = $phpcsFile->getTokens();
72+
if ($this->isOperator($phpcsFile, $stackPtr) === false) {
73+
return;
74+
}
6775

6876
$operator = $tokens[$stackPtr]['content'];
6977

0 commit comments

Comments
 (0)