Skip to content

Commit 7436e45

Browse files
committed
Modernize: Squiz/ComparisonOperatorUsage: use class constant for constant array
1 parent e92957e commit 7436e45

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class ComparisonOperatorUsageSniff implements Sniff
1919
/**
2020
* A list of valid comparison operators.
2121
*
22-
* @var array
22+
* @var array<int|string, true>
2323
*/
24-
private static $validOps = [
24+
private const VALID_OPERATIONS = [
2525
T_IS_IDENTICAL => true,
2626
T_IS_NOT_IDENTICAL => true,
2727
T_LESS_THAN => true,
@@ -36,7 +36,7 @@ class ComparisonOperatorUsageSniff implements Sniff
3636
*
3737
* @var array<int|string, string>
3838
*/
39-
private static $invalidOps = [
39+
private const INVALID_OPERATIONS = [
4040
T_IS_EQUAL => '===',
4141
T_IS_NOT_EQUAL => '!==',
4242
T_BOOLEAN_NOT => '=== FALSE',
@@ -149,15 +149,15 @@ public function process(File $phpcsFile, $stackPtr)
149149

150150
for ($i = $start; $i <= $end; $i++) {
151151
$type = $tokens[$i]['code'];
152-
if (isset(self::$invalidOps[$type]) === true) {
152+
if (isset(self::INVALID_OPERATIONS[$type]) === true) {
153153
$error = 'Operator %s prohibited; use %s instead';
154154
$data = [
155155
$tokens[$i]['content'],
156-
self::$invalidOps[$type],
156+
self::INVALID_OPERATIONS[$type],
157157
];
158158
$phpcsFile->addError($error, $i, 'NotAllowed', $data);
159159
$foundOps++;
160-
} else if (isset(self::$validOps[$type]) === true) {
160+
} else if (isset(self::VALID_OPERATIONS[$type]) === true) {
161161
$foundOps++;
162162
}
163163

0 commit comments

Comments
 (0)