Skip to content

Commit 904ba49

Browse files
committed
Use the new Tokens constants
... throughout the code base.
1 parent 2879cd7 commit 904ba49

File tree

139 files changed

+543
-543
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+543
-543
lines changed

scripts/build-phar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function stripWhitespaceAndComments($fullpath, $config)
6363
continue;
6464
}
6565

66-
if (isset(Tokens::$emptyTokens[$token['code']]) === false) {
66+
if (isset(Tokens::EMPTY_TOKENS[$token['code']]) === false) {
6767
$stripped .= $token['content'];
6868
continue;
6969
}

src/Files/File.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,7 +1560,7 @@ public function getMethodParameters($stackPtr)
15601560
$paramCount++;
15611561
break;
15621562
case T_EQUAL:
1563-
$defaultStart = $this->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
1563+
$defaultStart = $this->findNext(Tokens::EMPTY_TOKENS, ($i + 1), null, true);
15641564
$equalToken = $i;
15651565
break;
15661566
}//end switch
@@ -1676,7 +1676,7 @@ public function getMethodProperties($stackPtr)
16761676
$scopeOpener = $this->tokens[$stackPtr]['scope_opener'];
16771677
}
16781678

1679-
$valid = Tokens::$nameTokens;
1679+
$valid = Tokens::NAME_TOKENS;
16801680
$valid += [
16811681
T_CALLABLE => T_CALLABLE,
16821682
T_SELF => T_SELF,
@@ -1794,7 +1794,7 @@ public function getMemberProperties($stackPtr)
17941794
$conditions = array_keys($conditions);
17951795
$ptr = array_pop($conditions);
17961796
if (isset($this->tokens[$ptr]) === false
1797-
|| isset(Tokens::$ooScopeTokens[$this->tokens[$ptr]['code']]) === false
1797+
|| isset(Tokens::OO_SCOPE_TOKENS[$this->tokens[$ptr]['code']]) === false
17981798
|| $this->tokens[$ptr]['code'] === T_ENUM
17991799
) {
18001800
throw new RuntimeException('$stackPtr is not a class member var');
@@ -1822,7 +1822,7 @@ public function getMemberProperties($stackPtr)
18221822
T_FINAL => T_FINAL,
18231823
];
18241824

1825-
$valid += Tokens::$emptyTokens;
1825+
$valid += Tokens::EMPTY_TOKENS;
18261826

18271827
$scope = 'public';
18281828
$scopeSpecified = false;
@@ -1877,7 +1877,7 @@ public function getMemberProperties($stackPtr)
18771877

18781878
if ($i < $stackPtr) {
18791879
// We've found a type.
1880-
$valid = Tokens::$nameTokens;
1880+
$valid = Tokens::NAME_TOKENS;
18811881
$valid += [
18821882
T_CALLABLE => T_CALLABLE,
18831883
T_SELF => T_SELF,
@@ -2014,7 +2014,7 @@ public function isReference($stackPtr)
20142014
}
20152015

20162016
$tokenBefore = $this->findPrevious(
2017-
Tokens::$emptyTokens,
2017+
Tokens::EMPTY_TOKENS,
20182018
($stackPtr - 1),
20192019
null,
20202020
true
@@ -2038,14 +2038,14 @@ public function isReference($stackPtr)
20382038
return true;
20392039
}
20402040

2041-
if (isset(Tokens::$assignmentTokens[$this->tokens[$tokenBefore]['code']]) === true) {
2041+
if (isset(Tokens::ASSIGNMENT_TOKENS[$this->tokens[$tokenBefore]['code']]) === true) {
20422042
// This is directly after an assignment. It's a reference. Even if
20432043
// it is part of an operation, the other tests will handle it.
20442044
return true;
20452045
}
20462046

20472047
$tokenAfter = $this->findNext(
2048-
Tokens::$emptyTokens,
2048+
Tokens::EMPTY_TOKENS,
20492049
($stackPtr + 1),
20502050
null,
20512051
true
@@ -2084,8 +2084,8 @@ public function isReference($stackPtr)
20842084
if ($this->tokens[$tokenAfter]['code'] === T_VARIABLE) {
20852085
return true;
20862086
} else {
2087-
$skip = Tokens::$emptyTokens;
2088-
$skip += Tokens::$nameTokens;
2087+
$skip = Tokens::EMPTY_TOKENS;
2088+
$skip += Tokens::NAME_TOKENS;
20892089
$skip[] = T_SELF;
20902090
$skip[] = T_PARENT;
20912091
$skip[] = T_STATIC;
@@ -2309,7 +2309,7 @@ public function findNext(
23092309
*/
23102310
public function findStartOfStatement($start, $ignore=null)
23112311
{
2312-
$startTokens = Tokens::$blockOpeners;
2312+
$startTokens = Tokens::BLOCK_OPENERS;
23132313
$startTokens[T_OPEN_SHORT_ARRAY] = true;
23142314
$startTokens[T_OPEN_TAG] = true;
23152315
$startTokens[T_OPEN_TAG_WITH_ECHO] = true;
@@ -2395,7 +2395,7 @@ public function findStartOfStatement($start, $ignore=null)
23952395
// If it is the scope opener, go the first non-empty token after. $start will have been part of the first condition.
23962396
if ($prevMatch <= $this->tokens[$matchExpression]['scope_opener']) {
23972397
// We're before the arrow in the first case.
2398-
$next = $this->findNext(Tokens::$emptyTokens, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true);
2398+
$next = $this->findNext(Tokens::EMPTY_TOKENS, ($this->tokens[$matchExpression]['scope_opener'] + 1), null, true);
23992399
if ($next === false) {
24002400
// Shouldn't be possible.
24012401
return $start;
@@ -2412,7 +2412,7 @@ public function findStartOfStatement($start, $ignore=null)
24122412
}
24132413

24142414
// In both cases, go to the first non-empty token after.
2415-
$next = $this->findNext(Tokens::$emptyTokens, ($prevMatch + 1), null, true);
2415+
$next = $this->findNext(Tokens::EMPTY_TOKENS, ($prevMatch + 1), null, true);
24162416
if ($next === false) {
24172417
// Shouldn't be possible.
24182418
return $start;
@@ -2480,7 +2480,7 @@ public function findStartOfStatement($start, $ignore=null)
24802480
}
24812481
}//end if
24822482

2483-
if (isset(Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) {
2483+
if (isset(Tokens::EMPTY_TOKENS[$this->tokens[$i]['code']]) === false) {
24842484
$lastNotEmpty = $i;
24852485
}
24862486
}//end for
@@ -2575,7 +2575,7 @@ public function findEndOfStatement($start, $ignore=null)
25752575
continue;
25762576
}
25772577

2578-
if ($i === $start && isset(Tokens::$scopeOpeners[$this->tokens[$i]['code']]) === true) {
2578+
if ($i === $start && isset(Tokens::SCOPE_OPENERS[$this->tokens[$i]['code']]) === true) {
25792579
return $this->tokens[$i]['scope_closer'];
25802580
}
25812581

@@ -2595,7 +2595,7 @@ public function findEndOfStatement($start, $ignore=null)
25952595
}
25962596
}//end if
25972597

2598-
if (isset(Tokens::$emptyTokens[$this->tokens[$i]['code']]) === false) {
2598+
if (isset(Tokens::EMPTY_TOKENS[$this->tokens[$i]['code']]) === false) {
25992599
$lastNotEmpty = $i;
26002600
}
26012601
}//end for
@@ -2778,7 +2778,7 @@ public function findExtendedClassName($stackPtr)
27782778
return false;
27792779
}
27802780

2781-
$find = Tokens::$nameTokens;
2781+
$find = Tokens::NAME_TOKENS;
27822782
$find[] = T_WHITESPACE;
27832783

27842784
$end = $this->findNext($find, ($extendsIndex + 1), ($classOpenerIndex + 1), true);
@@ -2827,7 +2827,7 @@ public function findImplementedInterfaceNames($stackPtr)
28272827
return false;
28282828
}
28292829

2830-
$find = Tokens::$nameTokens;
2830+
$find = Tokens::NAME_TOKENS;
28312831
$find[] = T_WHITESPACE;
28322832
$find[] = T_COMMA;
28332833

src/Sniffs/AbstractArraySniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function process(File $phpcsFile, $stackPtr)
6060
$arrayEnd = $tokens[$stackPtr]['bracket_closer'];
6161
}
6262

63-
$lastContent = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($arrayEnd - 1), null, true);
63+
$lastContent = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($arrayEnd - 1), null, true);
6464
if ($tokens[$lastContent]['code'] === T_COMMA) {
6565
// Last array item ends with a comma.
6666
$phpcsFile->recordMetric($stackPtr, 'Array end comma', 'yes');
@@ -71,12 +71,12 @@ public function process(File $phpcsFile, $stackPtr)
7171
$indices = [];
7272

7373
$current = $arrayStart;
74-
while (($next = $phpcsFile->findNext(Tokens::$emptyTokens, ($current + 1), $arrayEnd, true)) !== false) {
74+
while (($next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($current + 1), $arrayEnd, true)) !== false) {
7575
$end = $this->getNext($phpcsFile, $next, $arrayEnd);
7676

7777
if ($tokens[$end]['code'] === T_DOUBLE_ARROW) {
7878
$indexEnd = $phpcsFile->findPrevious(T_WHITESPACE, ($end - 1), null, true);
79-
$valueStart = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
79+
$valueStart = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($end + 1), null, true);
8080

8181
$indices[] = [
8282
'index_start' => $next,

src/Sniffs/AbstractPatternSniff.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
256256

257257
$ignoreTokens = [T_WHITESPACE => T_WHITESPACE];
258258
if ($this->ignoreComments === true) {
259-
$ignoreTokens += Tokens::$commentTokens;
259+
$ignoreTokens += Tokens::COMMENT_TOKENS;
260260
}
261261

262262
$origStackPtr = $stackPtr;
@@ -350,10 +350,10 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
350350
$found = 'abc';
351351
} else if ($pattern[$i]['type'] === 'newline') {
352352
if ($this->ignoreComments === true
353-
&& isset(Tokens::$commentTokens[$tokens[$stackPtr]['code']]) === true
353+
&& isset(Tokens::COMMENT_TOKENS[$tokens[$stackPtr]['code']]) === true
354354
) {
355355
$startComment = $phpcsFile->findPrevious(
356-
Tokens::$commentTokens,
356+
Tokens::COMMENT_TOKENS,
357357
($stackPtr - 1),
358358
null,
359359
true
@@ -381,7 +381,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
381381
// can ignore the error here.
382382
if (($tokens[($stackPtr - 1)]['content'] !== $phpcsFile->eolChar)
383383
&& ($this->ignoreComments === true
384-
&& isset(Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === false)
384+
&& isset(Tokens::COMMENT_TOKENS[$tokens[($stackPtr - 1)]['code']]) === false)
385385
) {
386386
$hasError = true;
387387
} else {
@@ -425,15 +425,15 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
425425
if ($this->ignoreComments === true) {
426426
// If we are ignoring comments, check to see if this current
427427
// token is a comment. If so skip it.
428-
if (isset(Tokens::$commentTokens[$tokens[$stackPtr]['code']]) === true) {
428+
if (isset(Tokens::COMMENT_TOKENS[$tokens[$stackPtr]['code']]) === true) {
429429
continue;
430430
}
431431

432432
// If the next token is a comment, the we need to skip the
433433
// current token as we should allow a space before a
434434
// comment for readability.
435435
if (isset($tokens[($stackPtr + 1)]) === true
436-
&& isset(Tokens::$commentTokens[$tokens[($stackPtr + 1)]['code']]) === true
436+
&& isset(Tokens::COMMENT_TOKENS[$tokens[($stackPtr + 1)]['code']]) === true
437437
) {
438438
continue;
439439
}
@@ -448,7 +448,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
448448
} else {
449449
// Get all the whitespace to the next token.
450450
$next = $phpcsFile->findNext(
451-
Tokens::$emptyTokens,
451+
Tokens::EMPTY_TOKENS,
452452
$stackPtr,
453453
null,
454454
true
@@ -535,7 +535,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
535535
$hasComment = false;
536536
for ($j = $stackPtr; $j < $next; $j++) {
537537
$found .= $tokens[$j]['content'];
538-
if (isset(Tokens::$commentTokens[$tokens[$j]['code']]) === true) {
538+
if (isset(Tokens::COMMENT_TOKENS[$tokens[$j]['code']]) === true) {
539539
$hasComment = true;
540540
}
541541
}
@@ -590,7 +590,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
590590
} else {
591591
// Find the previous opener.
592592
$next = $phpcsFile->findPrevious(
593-
Tokens::$blockOpeners,
593+
Tokens::BLOCK_OPENERS,
594594
$stackPtr
595595
);
596596

@@ -640,7 +640,7 @@ protected function processPattern($patternInfo, File $phpcsFile, $stackPtr)
640640
} else {
641641
if ($this->ignoreComments === false) {
642642
// The newline character cannot be part of a comment.
643-
if (isset(Tokens::$commentTokens[$tokens[$newline]['code']]) === true) {
643+
if (isset(Tokens::COMMENT_TOKENS[$tokens[$newline]['code']]) === true) {
644644
$hasError = true;
645645
}
646646
}

src/Sniffs/AbstractVariableSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
4949
*/
5050
public function __construct()
5151
{
52-
$scopes = Tokens::$ooScopeTokens;
52+
$scopes = Tokens::OO_SCOPE_TOKENS;
5353

5454
$listen = [
5555
T_VARIABLE,
@@ -97,7 +97,7 @@ final protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $cu
9797
$conditions = array_reverse($tokens[$stackPtr]['conditions'], true);
9898
$inFunction = false;
9999
foreach ($conditions as $scope => $code) {
100-
if (isset(Tokens::$ooScopeTokens[$code]) === true) {
100+
if (isset(Tokens::OO_SCOPE_TOKENS[$code]) === true) {
101101
break;
102102
}
103103

src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
6060
$tokens = $phpcsFile->getTokens();
6161

6262
// Determine how far indented the entire array declaration should be.
63-
$ignore = Tokens::$emptyTokens;
63+
$ignore = Tokens::EMPTY_TOKENS;
6464
$ignore[] = T_DOUBLE_ARROW;
6565
$prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
6666
$start = $phpcsFile->findStartOfStatement($prev);
@@ -108,7 +108,7 @@ public function processMultiLineArray($phpcsFile, $stackPtr, $arrayStart, $array
108108
$start = $index['value_start'];
109109
}
110110

111-
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($start - 1), null, true);
111+
$prev = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($start - 1), null, true);
112112
if ($tokens[$prev]['line'] === $tokens[$start]['line']) {
113113
// This index isn't the only content on the line
114114
// so we can't check indent rules.

src/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr)
6262
while ($stackPtr !== false) {
6363
// Keep track of what namespace we are in.
6464
if ($tokens[$stackPtr]['code'] === T_NAMESPACE) {
65-
$nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
65+
$nextNonEmpty = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($stackPtr + 1), null, true);
6666
if ($nextNonEmpty !== false) {
6767
if ($tokens[$nextNonEmpty]['code'] === T_STRING
6868
|| $tokens[$nextNonEmpty]['code'] === T_NAME_QUALIFIED

src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class AssignmentInConditionSniff implements Sniff
4444
*/
4545
public function register()
4646
{
47-
$this->assignmentTokens = Tokens::$assignmentTokens;
47+
$this->assignmentTokens = Tokens::ASSIGNMENT_TOKENS;
4848
unset($this->assignmentTokens[T_DOUBLE_ARROW]);
4949

50-
$starters = Tokens::$booleanOperators;
50+
$starters = Tokens::BOOLEAN_OPERATORS;
5151
$starters[T_SEMICOLON] = T_SEMICOLON;
5252
$starters[T_OPEN_PARENTHESIS] = T_OPEN_PARENTHESIS;
5353

@@ -133,7 +133,7 @@ public function process(File $phpcsFile, $stackPtr)
133133
}
134134

135135
for ($i = $hasAssignment; $i > $conditionStart; $i--) {
136-
if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === true) {
136+
if (isset(Tokens::EMPTY_TOKENS[$tokens[$i]['code']]) === true) {
137137
continue;
138138
}
139139

src/Standards/Generic/Sniffs/CodeAnalysis/EmptyPHPStatementSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private function processSemicolon(File $phpcsFile, $stackPtr)
7070
{
7171
$tokens = $phpcsFile->getTokens();
7272

73-
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
73+
$prevNonEmpty = $phpcsFile->findPrevious(Tokens::EMPTY_TOKENS, ($stackPtr - 1), null, true);
7474
if ($tokens[$prevNonEmpty]['code'] !== T_SEMICOLON
7575
&& $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG
7676
&& $tokens[$prevNonEmpty]['code'] !== T_OPEN_TAG_WITH_ECHO

src/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr)
7676
}
7777

7878
$next = $phpcsFile->findNext(
79-
Tokens::$emptyTokens,
79+
Tokens::EMPTY_TOKENS,
8080
($token['scope_opener'] + 1),
8181
($token['scope_closer'] - 1),
8282
true

0 commit comments

Comments
 (0)