Skip to content

Commit b05f769

Browse files
committed
PHP 8.0 | Generic.CodeAnalysis.EmptyPHPStatement: add support for match
1 parent ef0273a commit b05f769

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function process(File $phpcsFile, $stackPtr)
7272
}
7373

7474
$scopeOwner = $tokens[$tokens[$prevNonEmpty]['scope_condition']]['code'];
75-
if ($scopeOwner === T_CLOSURE || $scopeOwner === T_ANON_CLASS) {
75+
if ($scopeOwner === T_CLOSURE || $scopeOwner === T_ANON_CLASS || $scopeOwner === T_MATCH) {
7676
return;
7777
}
7878

src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,8 @@ echo $a{0};
7979
if ($foo) {
8080
;
8181
}
82+
83+
// Do not remove semicolon after match
84+
$c = match ($a) {
85+
1 => true,
86+
};

src/Standards/Generic/Tests/CodeAnalysis/EmptyPHPStatementUnitTest.inc.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,8 @@ echo $a{0};
7373

7474
if ($foo) {
7575
}
76+
77+
// Do not remove semicolon after match
78+
$c = match ($a) {
79+
1 => true,
80+
};

0 commit comments

Comments
 (0)