18
18
abstract class Tokenizer
19
19
{
20
20
21
+ /**
22
+ * List of tokens which may contain tab characters.
23
+ *
24
+ * @var array<int|string, true>
25
+ */
26
+ private const TOKENS_WITH_TABS = [
27
+ T_WHITESPACE => true ,
28
+ T_COMMENT => true ,
29
+ T_DOC_COMMENT => true ,
30
+ T_DOC_COMMENT_WHITESPACE => true ,
31
+ T_DOC_COMMENT_STRING => true ,
32
+ T_CONSTANT_ENCAPSED_STRING => true ,
33
+ T_DOUBLE_QUOTED_STRING => true ,
34
+ T_START_HEREDOC => true ,
35
+ T_START_NOWDOC => true ,
36
+ T_HEREDOC => true ,
37
+ T_NOWDOC => true ,
38
+ T_END_HEREDOC => true ,
39
+ T_END_NOWDOC => true ,
40
+ T_INLINE_HTML => true ,
41
+ T_YIELD_FROM => true ,
42
+ ];
43
+
21
44
/**
22
45
* The config data for the run.
23
46
*
@@ -188,24 +211,6 @@ private function createPositionMap()
188
211
$ encoding = $ this ->config ->encoding ;
189
212
$ tabWidth = $ this ->config ->tabWidth ;
190
213
191
- $ tokensWithTabs = [
192
- T_WHITESPACE => true ,
193
- T_COMMENT => true ,
194
- T_DOC_COMMENT => true ,
195
- T_DOC_COMMENT_WHITESPACE => true ,
196
- T_DOC_COMMENT_STRING => true ,
197
- T_CONSTANT_ENCAPSED_STRING => true ,
198
- T_DOUBLE_QUOTED_STRING => true ,
199
- T_START_HEREDOC => true ,
200
- T_START_NOWDOC => true ,
201
- T_HEREDOC => true ,
202
- T_NOWDOC => true ,
203
- T_END_HEREDOC => true ,
204
- T_END_NOWDOC => true ,
205
- T_INLINE_HTML => true ,
206
- T_YIELD_FROM => true ,
207
- ];
208
-
209
214
$ this ->numTokens = count ($ this ->tokens );
210
215
for ($ i = 0 ; $ i < $ this ->numTokens ; $ i ++) {
211
216
$ this ->tokens [$ i ]['line ' ] = $ lineNumber ;
@@ -216,7 +221,7 @@ private function createPositionMap()
216
221
$ length = $ this ->knownLengths [$ this ->tokens [$ i ]['code ' ]];
217
222
$ currColumn += $ length ;
218
223
} else if ($ tabWidth === 0
219
- || isset ($ tokensWithTabs [$ this ->tokens [$ i ]['code ' ]]) === false
224
+ || isset (self :: TOKENS_WITH_TABS [$ this ->tokens [$ i ]['code ' ]]) === false
220
225
|| strpos ($ this ->tokens [$ i ]['content ' ], "\t" ) === false
221
226
) {
222
227
// There are no tabs in this content, or we aren't replacing them.
0 commit comments