Skip to content

Commit 0b40b13

Browse files
committed
PHP 8.0 | Generic/LowerCaseKeyword: add match to keyword list
This adds the PHP 8.0 `match` keyword to the list handled by this sniff, as well as the `default` keyword when used in a match control structure. Includes unit tests.
1 parent 8b0137a commit 0b40b13

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public function register()
7373
T_LOGICAL_AND,
7474
T_LOGICAL_OR,
7575
T_LOGICAL_XOR,
76+
T_MATCH,
77+
T_MATCH_DEFAULT,
7678
T_NAMESPACE,
7779
T_NEW,
7880
T_PARENT,

src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,11 @@ class X extends Y {
2929
}
3030
}
3131
FN ($x) => $x;
32+
$r = Match ($x) {
33+
1 => 1,
34+
2 => 2,
35+
DEFAULT, => 3,
36+
};
37+
3238
__HALT_COMPILER(); // An exception due to phar support.
3339
function

src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,11 @@ class X extends Y {
2929
}
3030
}
3131
fn ($x) => $x;
32+
$r = match ($x) {
33+
1 => 1,
34+
2 => 2,
35+
default, => 3,
36+
};
37+
3238
__HALT_COMPILER(); // An exception due to phar support.
3339
function

src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public function getErrorList()
3838
25 => 1,
3939
28 => 1,
4040
31 => 1,
41+
32 => 1,
42+
35 => 1,
4143
];
4244

4345
}//end getErrorList()

0 commit comments

Comments
 (0)