Skip to content

Commit 500e653

Browse files
committed
Modernize: PSR12/ConstantVisibility: use class constant for constant array
1 parent 33a89dd commit 500e653

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Standards/PSR12/Sniffs/Properties/ConstantVisibilitySniff.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@
1616
class ConstantVisibilitySniff implements Sniff
1717
{
1818

19+
/**
20+
* Visibility tokens which are valid for class constants.
21+
*
22+
* @var array<int, int>
23+
*/
24+
private const VALID_VISIBILITY = [
25+
T_PRIVATE => T_PRIVATE,
26+
T_PUBLIC => T_PUBLIC,
27+
T_PROTECTED => T_PROTECTED,
28+
];
29+
1930

2031
/**
2132
* Returns an array of tokens this test wants to listen for.
@@ -50,14 +61,8 @@ public function process(File $phpcsFile, $stackPtr)
5061
$ignore = Tokens::EMPTY_TOKENS;
5162
$ignore[] = T_FINAL;
5263

53-
$validVisibility = [
54-
T_PRIVATE => T_PRIVATE,
55-
T_PUBLIC => T_PUBLIC,
56-
T_PROTECTED => T_PROTECTED,
57-
];
58-
5964
$prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
60-
if (isset($validVisibility[$tokens[$prev]['code']]) === true) {
65+
if (isset(self::VALID_VISIBILITY[$tokens[$prev]['code']]) === true) {
6166
return;
6267
}
6368

0 commit comments

Comments
 (0)