Skip to content

Commit dffc59e

Browse files
committed
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 8b0137a commit dffc59e

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
@@ -53,6 +53,7 @@ public function register()
5353
T_ELSE,
5454
T_ELSEIF,
5555
T_SWITCH,
56+
T_MATCH,
5657
];
5758

5859
}//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
@@ -76,6 +76,7 @@ public function getErrorList($testFile='ControlSignatureUnitTest.inc')
7676
$errors[276] = 1;
7777
$errors[279] = 1;
7878
$errors[283] = 1;
79+
$errors[306] = 3;
7980
}//end if
8081

8182
return $errors;

0 commit comments

Comments
 (0)