Skip to content

Commit

Permalink
PHP 8.0 | Generic/LowerCaseKeyword: add match to keyword list
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Feb 23, 2021
1 parent 8b0137a commit 0b40b13
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public function register()
T_LOGICAL_AND,
T_LOGICAL_OR,
T_LOGICAL_XOR,
T_MATCH,
T_MATCH_DEFAULT,
T_NAMESPACE,
T_NEW,
T_PARENT,
Expand Down
6 changes: 6 additions & 0 deletions src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ class X extends Y {
}
}
FN ($x) => $x;
$r = Match ($x) {
1 => 1,
2 => 2,
DEFAULT, => 3,
};

__HALT_COMPILER(); // An exception due to phar support.
function
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ class X extends Y {
}
}
fn ($x) => $x;
$r = match ($x) {
1 => 1,
2 => 2,
default, => 3,
};

__HALT_COMPILER(); // An exception due to phar support.
function
2 changes: 2 additions & 0 deletions src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public function getErrorList()
25 => 1,
28 => 1,
31 => 1,
32 => 1,
35 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 0b40b13

Please sign in to comment.