Skip to content

Commit 557756c

Browse files
committed
Squiz.PHP.DisallowMultipleAssignmentsSniff: Fixed false positive when assigment is after goto label
1 parent c19a0f5 commit 557756c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public function process(File $phpcsFile, $stackPtr)
146146

147147
if ($tokens[$varToken]['code'] === T_VARIABLE
148148
|| $tokens[$varToken]['code'] === T_OPEN_TAG
149+
|| $tokens[$varToken]['code'] === T_GOTO_LABEL
149150
|| $tokens[$varToken]['code'] === T_INLINE_THEN
150151
|| $tokens[$varToken]['code'] === T_INLINE_ELSE
151152
|| $tokens[$varToken]['code'] === T_SEMICOLON

src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ function ($html) {
9898
return $all;
9999
}, $html);
100100
};
101+
102+
103+
function () {
104+
$a = false;
105+
106+
some_label:
107+
108+
$b = getB();
109+
};
110+

0 commit comments

Comments
 (0)