Skip to content

Commit e749e95

Browse files
committed
Modernize: Generic/LowerCaseType: use class constant for constant array
1 parent 0e18ef7 commit e749e95

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class LowerCaseTypeSniff implements Sniff
2020
/**
2121
* Native types supported by PHP.
2222
*
23-
* @var array
23+
* @var array<string, true>
2424
*/
25-
private $phpTypes = [
25+
private const PHP_TYPES = [
2626
'self' => true,
2727
'parent' => true,
2828
'array' => true,
@@ -146,7 +146,7 @@ public function process(File $phpcsFile, $stackPtr)
146146
);
147147
} else {
148148
$type = $tokens[$startOfType]['content'];
149-
if (isset($this->phpTypes[strtolower($type)]) === true) {
149+
if (isset(self::PHP_TYPES[strtolower($type)]) === true) {
150150
$this->processType($phpcsFile, $startOfType, $type, $error, $errorCode);
151151
}
152152
}
@@ -182,7 +182,7 @@ public function process(File $phpcsFile, $stackPtr)
182182
$error,
183183
$errorCode
184184
);
185-
} else if (isset($this->phpTypes[strtolower($type)]) === true) {
185+
} else if (isset(self::PHP_TYPES[strtolower($type)]) === true) {
186186
$this->processType($phpcsFile, $props['type_token'], $type, $error, $errorCode);
187187
}
188188
}
@@ -213,7 +213,7 @@ public function process(File $phpcsFile, $stackPtr)
213213
$error,
214214
$errorCode
215215
);
216-
} else if (isset($this->phpTypes[strtolower($returnType)]) === true) {
216+
} else if (isset(self::PHP_TYPES[strtolower($returnType)]) === true) {
217217
$this->processType($phpcsFile, $props['return_type_token'], $returnType, $error, $errorCode);
218218
}
219219
}
@@ -244,7 +244,7 @@ public function process(File $phpcsFile, $stackPtr)
244244
$error,
245245
$errorCode
246246
);
247-
} else if (isset($this->phpTypes[strtolower($typeHint)]) === true) {
247+
} else if (isset(self::PHP_TYPES[strtolower($typeHint)]) === true) {
248248
$this->processType($phpcsFile, $param['type_hint_token'], $typeHint, $error, $errorCode);
249249
}
250250
}
@@ -285,7 +285,7 @@ protected function processUnionType(File $phpcsFile, $typeDeclStart, $typeDeclEn
285285
) {
286286
if ($typeTokenCount === 1
287287
&& $type !== ''
288-
&& isset($this->phpTypes[strtolower($type)]) === true
288+
&& isset(self::PHP_TYPES[strtolower($type)]) === true
289289
) {
290290
$this->processType($phpcsFile, $typeStart, $type, $error, $errorCode);
291291
}
@@ -309,7 +309,7 @@ protected function processUnionType(File $phpcsFile, $typeDeclStart, $typeDeclEn
309309
// Handle type at end of type string.
310310
if ($typeTokenCount === 1
311311
&& $type !== ''
312-
&& isset($this->phpTypes[strtolower($type)]) === true
312+
&& isset(self::PHP_TYPES[strtolower($type)]) === true
313313
) {
314314
$this->processType($phpcsFile, $typeStart, $type, $error, $errorCode);
315315
}

0 commit comments

Comments
 (0)