Skip to content

Commit bf7d788

Browse files
jrfnlgsherwood
authored andcommitted
PHP 8.0 | Squiz/ControlSignature: check signature of match expressions
This adds support for checking the signature of `match` expressions to this sniff. Includes unit test.
1 parent 992cc6b commit bf7d788

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function register()
4343
T_ELSE,
4444
T_ELSEIF,
4545
T_SWITCH,
46+
T_MATCH,
4647
];
4748

4849
}//end register()

src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,12 @@ while ( $level-- ):
299299
ob_end_clean();
300300
endwhile;
301301

302+
$r = match ($x) {
303+
1 => 1,
304+
};
305+
306+
$r = match($x){1 => 1};
307+
302308
// Intentional parse error. This should be the last test in the file.
303309
foreach
304310
// Some unrelated comment.

src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ while ( $level-- ):
302302
ob_end_clean();
303303
endwhile;
304304

305+
$r = match ($x) {
306+
1 => 1,
307+
};
308+
309+
$r = match ($x) {
310+
1 => 1};
311+
305312
// Intentional parse error. This should be the last test in the file.
306313
foreach
307314
// Some unrelated comment.

src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ public function getErrorList()
7171
276 => 1,
7272
279 => 1,
7373
283 => 1,
74+
306 => 3,
7475
];
7576

7677
}//end getErrorList()

0 commit comments

Comments
 (0)