Skip to content

Commit 6836945

Browse files
committed
Merge branch 'php-8.0/squiz-disallowmultipleassignments-support-match' of https://github.com/jrfnl/PHP_CodeSniffer
2 parents 3095cb6 + 87bc198 commit 6836945

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ public function process(File $phpcsFile, $stackPtr)
165165
T_SWITCH => T_SWITCH,
166166
T_CASE => T_CASE,
167167
T_FOR => T_FOR,
168+
T_MATCH => T_MATCH,
168169
];
169170
foreach ($nested as $opener => $closer) {
170171
if (isset($tokens[$opener]['parenthesis_owner']) === true

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,15 @@ class Bar
7575
public bool $c = false, $d = true;
7676
protected int $e = 123, $f = 987;
7777
}
78+
79+
switch ($b < 10 && $a = 10) {
80+
case true:
81+
break;
82+
}
83+
84+
$array = [
85+
match ($b < 10 && $a = 10) {
86+
true => 10,
87+
false => 0
88+
},
89+
];

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public function getErrorList()
3333
12 => 1,
3434
14 => 1,
3535
15 => 1,
36+
79 => 1,
37+
85 => 1,
3638
];
3739

3840
}//end getErrorList()

0 commit comments

Comments
 (0)