Skip to content

Commit f8f9296

Browse files
committed
Modernize: Generic/DisallowTabIndent: use class constant for constant array
1 parent b184050 commit f8f9296

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@
1515
class DisallowTabIndentSniff implements Sniff
1616
{
1717

18+
/**
19+
* Tokens which can include indentation.
20+
*
21+
* @var array<int|string, true>
22+
*/
23+
private const TOKENS_CONTAINING_INDENT = [
24+
T_WHITESPACE => true,
25+
T_INLINE_HTML => true,
26+
T_DOC_COMMENT_WHITESPACE => true,
27+
T_DOC_COMMENT_STRING => true,
28+
T_COMMENT => true,
29+
T_END_HEREDOC => true,
30+
T_END_NOWDOC => true,
31+
T_YIELD_FROM => true,
32+
];
33+
1834
/**
1935
* The --tab-width CLI value that is being used.
2036
*
@@ -58,20 +74,10 @@ public function process(File $phpcsFile, $stackPtr)
5874
}
5975
}
6076

61-
$tokens = $phpcsFile->getTokens();
62-
$checkTokens = [
63-
T_WHITESPACE => true,
64-
T_INLINE_HTML => true,
65-
T_DOC_COMMENT_WHITESPACE => true,
66-
T_DOC_COMMENT_STRING => true,
67-
T_COMMENT => true,
68-
T_END_HEREDOC => true,
69-
T_END_NOWDOC => true,
70-
T_YIELD_FROM => true,
71-
];
77+
$tokens = $phpcsFile->getTokens();
7278

7379
for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
74-
if (isset($checkTokens[$tokens[$i]['code']]) === false) {
80+
if (isset(self::TOKENS_CONTAINING_INDENT[$tokens[$i]['code']]) === false) {
7581
continue;
7682
}
7783

0 commit comments

Comments
 (0)