Skip to content

Commit adb8595

Browse files
Sylvain Vanelklausi
authored andcommitted
3548073: Fix PHP_CS deprecated and breaking changes
1 parent 07c14cf commit adb8595

Some content is hidden

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

48 files changed

+92
-304
lines changed

.cspell.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"addtogroup",
2323
"autoloader",
2424
"codesniffer",
25-
"ColourDefinitionSniff",
2625
"CURLOPT_SSL_VERIFYPEER",
2726
"datestamp",
2827
"defgroup",
@@ -43,7 +42,6 @@
4342
"startOfLine",
4443
"Superglobal",
4544
"T_ASPERAND",
46-
"T_COLOUR",
4745
"T_CONSTANT_ENCAPSED_STRING",
4846
"T_DNUMBER",
4947
"T_LNUMBER",

coder_sniffer/Drupal/Sniffs/Arrays/ArraySniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function process(File $phpcsFile, $stackPtr)
8383
}
8484

8585
$lastItem = $phpcsFile->findPrevious(
86-
Tokens::$emptyTokens,
86+
Tokens::EMPTY_TOKENS,
8787
($tokens[$stackPtr][$parenthesisCloser] - 1),
8888
$stackPtr,
8989
true
@@ -101,7 +101,7 @@ public function process(File $phpcsFile, $stackPtr)
101101
if ($tokens[$lastItem]['code'] !== T_COMMA && $isInlineArray === false
102102
&& $tokens[($lastItem + 1)]['code'] !== T_CLOSE_PARENTHESIS
103103
&& $tokens[($lastItem + 1)]['code'] !== T_CLOSE_SHORT_ARRAY
104-
&& isset(Tokens::$heredocTokens[$tokens[$lastItem]['code']]) === false
104+
&& isset(Tokens::HEREDOC_TOKENS[$tokens[$lastItem]['code']]) === false
105105
) {
106106
$data = [$tokens[$lastItem]['content']];
107107
$fix = $phpcsFile->addFixableWarning('A comma should follow the last multiline array item. Found: %s', $lastItem, 'CommaLastItem', $data);
@@ -195,7 +195,7 @@ public function process(File $phpcsFile, $stackPtr)
195195
$currentLine = $tokens[$newLineStart]['line'];
196196
while ($currentLine >= $tokens[$newLineStart]['line']) {
197197
$newLineStart = $phpcsFile->findNext(
198-
Tokens::$emptyTokens,
198+
Tokens::EMPTY_TOKENS,
199199
($newLineStart + 1),
200200
($tokens[$stackPtr][$parenthesisCloser] + 1),
201201
true
@@ -284,7 +284,7 @@ public function process(File $phpcsFile, $stackPtr)
284284
$isMultiLineString = $tokens[($newLineStart - 1)]['code'] === T_CONSTANT_ENCAPSED_STRING
285285
&& substr($tokens[($newLineStart - 1)]['content'], -1) === $phpcsFile->eolChar;
286286
// Skip NOWDOC or HEREDOC lines.
287-
$nowDoc = isset(Tokens::$heredocTokens[$tokens[$newLineStart]['code']]);
287+
$nowDoc = isset(Tokens::HEREDOC_TOKENS[$tokens[$newLineStart]['code']]);
288288
if ($innerNesting === false && $isMultiLineString === false && $nowDoc === false) {
289289
$error = 'Array indentation error, expected %s spaces but found %s';
290290
$data = [

coder_sniffer/Drupal/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php

Lines changed: 0 additions & 100 deletions
This file was deleted.

coder_sniffer/Drupal/Sniffs/CSS/ColourDefinitionSniff.php

Lines changed: 0 additions & 99 deletions
This file was deleted.

coder_sniffer/Drupal/Sniffs/Classes/ClassCreateInstanceSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function process(File $phpcsFile, $stackPtr)
6262
$nextParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), $commaOrColon);
6363
if ($nextParenthesis === false) {
6464
$error = 'Calling class constructors must always include parentheses';
65-
$constructor = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true);
65+
$constructor = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($stackPtr + 1), null, true, null, true);
6666
// We can invoke the fixer if we know this is a static constructor
6767
// function call or constructor calls with namespaces, example
6868
// "new \DOMDocument;" or constructor with class names in variables
@@ -76,7 +76,7 @@ public function process(File $phpcsFile, $stackPtr)
7676
$nextConstructorPart = $constructor;
7777
while (true) {
7878
$nextConstructorPart = $phpcsFile->findNext(
79-
Tokens::$emptyTokens,
79+
Tokens::EMPTY_TOKENS,
8080
($nextConstructorPart + 1),
8181
null,
8282
true,

coder_sniffer/Drupal/Sniffs/Classes/ClassDeclarationSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function processClose(File $phpcsFile, $stackPtr)
157157
if ($prevContent !== $tokens[$stackPtr]['scope_opener']
158158
&& $tokens[$prevContent]['line'] !== ($tokens[$closeBrace]['line'] - 2)
159159
// If the class only contains a comment no extra line is needed.
160-
&& isset(Tokens::$commentTokens[$tokens[$prevContent]['code']]) === false
160+
&& isset(Tokens::COMMENT_TOKENS[$tokens[$prevContent]['code']]) === false
161161
// Enums are allowed to enclose the cases without an extra line.
162162
&& $tokens[$stackPtr]['code'] !== T_ENUM
163163
) {

coder_sniffer/Drupal/Sniffs/Classes/ClassFileNameSniff.php

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

6868
$tokens = $phpcsFile->getTokens();
69-
$decName = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
69+
$decName = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($stackPtr + 1), null, true);
7070

7171
if ($tokens[$decName]['code'] === T_STRING
7272
&& $tokens[$decName]['content'] !== $fileName

coder_sniffer/Drupal/Sniffs/Classes/UnusedUseStatementSniff.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function process(File $phpcsFile, $stackPtr)
6161
}
6262

6363
$classPtr = $phpcsFile->findPrevious(
64-
Tokens::$emptyTokens,
64+
Tokens::EMPTY_TOKENS,
6565
($semiColon - 1),
6666
null,
6767
true
@@ -116,14 +116,8 @@ public function process(File $phpcsFile, $stackPtr)
116116

117117
while ($classUsed !== false) {
118118
if (strtolower($tokens[$classUsed]['content']) === $lowerClassName) {
119-
// If the name is used in a PHP 7 function return type declaration
120-
// stop.
121-
if ($tokens[$classUsed]['code'] === T_RETURN_TYPE) {
122-
return;
123-
}
124-
125119
$beforeUsage = $phpcsFile->findPrevious(
126-
Tokens::$emptyTokens,
120+
Tokens::EMPTY_TOKENS,
127121
($classUsed - 1),
128122
null,
129123
true
@@ -155,7 +149,7 @@ public function process(File $phpcsFile, $stackPtr)
155149
}
156150
}//end if
157151

158-
$classUsed = $phpcsFile->findNext([T_STRING, T_RETURN_TYPE], ($classUsed + 1));
152+
$classUsed = $phpcsFile->findNext([T_STRING], ($classUsed + 1));
159153
}//end while
160154

161155
$warning = 'Unused use statement';

coder_sniffer/Drupal/Sniffs/Classes/UseGlobalClassSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function process(File $phpcsFile, $stackPtr)
5656
$tokens = $phpcsFile->getTokens();
5757

5858
// Make sure this is not a closure USE group.
59-
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
59+
$next = $phpcsFile->findNext(Tokens::EMPTY_TOKENS, ($stackPtr + 1), null, true);
6060
if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) {
6161
return;
6262
}

coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.php

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

5757
$startPtr = $phpcsFile->findNext(
58-
Tokens::$emptyTokens,
58+
Tokens::EMPTY_TOKENS,
5959
($stackPtr + 1),
6060
null,
6161
true

0 commit comments

Comments
 (0)