Skip to content

Commit 92599f5

Browse files
committed
Modernize: Squiz/LongConditionClosingComment: use class constant for constant array
Includes changing the array format from a list of strings to an associative array with the key and value for each entry holding the same string to allow for using `isset()` instead of `in_array()`.
1 parent 43f8d67 commit 92599f5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ class LongConditionClosingCommentSniff implements Sniff
1616
{
1717

1818
/**
19-
* The openers that we are interested in.
19+
* The condition openers that we are interested in.
2020
*
21-
* @var array<int|string>
21+
* @var array<int|string, int|string>
2222
*/
23-
private static $openers = [
24-
T_SWITCH,
25-
T_IF,
26-
T_FOR,
27-
T_FOREACH,
28-
T_WHILE,
29-
T_TRY,
30-
T_CASE,
31-
T_MATCH,
23+
private const CONDITION_OPENERS = [
24+
T_SWITCH => T_SWITCH,
25+
T_IF => T_IF,
26+
T_FOR => T_FOR,
27+
T_FOREACH => T_FOREACH,
28+
T_WHILE => T_WHILE,
29+
T_TRY => T_TRY,
30+
T_CASE => T_CASE,
31+
T_MATCH => T_MATCH,
3232
];
3333

3434
/**
@@ -84,7 +84,7 @@ public function process(File $phpcsFile, $stackPtr)
8484
$endBrace = $tokens[$stackPtr];
8585

8686
// We are only interested in some code blocks.
87-
if (in_array($startCondition['code'], self::$openers, true) === false) {
87+
if (isset(self::CONDITION_OPENERS[$startCondition['code']]) === false) {
8888
return;
8989
}
9090

0 commit comments

Comments
 (0)