Skip to content

Commit 6b32f68

Browse files
jrfnlgsherwood
authored andcommitted
PHP 8.0 | Squiz/PostStatementComment: include match expressions
Allows the sniff to make an exception for comments within the condition of a match expression, just like it does for other control structures. Includes unit test.
1 parent 7ad38d7 commit 6b32f68

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

src/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class PostStatementCommentSniff implements Sniff
3030
T_WHILE => true,
3131
T_FOR => true,
3232
T_FOREACH => true,
33+
T_MATCH => true,
3334
];
3435

3536

src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ for (
4646
if ( $condition === true // comment
4747
&& $anotherCondition === false
4848
) {}
49+
50+
$match = match($foo // comment
51+
&& $bar
52+
) {
53+
1 => 1, // comment
54+
};

src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.inc.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ for (
5050
if ( $condition === true // comment
5151
&& $anotherCondition === false
5252
) {}
53+
54+
$match = match($foo // comment
55+
&& $bar
56+
) {
57+
1 => 1,
58+
// comment
59+
};

src/Standards/Squiz/Tests/Commenting/PostStatementCommentUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function getErrorList()
3030
10 => 1,
3131
18 => 1,
3232
35 => 1,
33+
53 => 1,
3334
];
3435

3536
}//end getErrorList()

0 commit comments

Comments
 (0)