Skip to content

Commit aa9bd2b

Browse files
committed
Fix up "Fix mis-identification of 'readonly' keyword"
... for changes between PHPCS 3.x vs 4.x.
1 parent 674b27a commit aa9bd2b

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/Tokenizers/PHP.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ protected function tokenize($string)
12541254
// Get the next non-whitespace token.
12551255
for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
12561256
if (is_array($tokens[$i]) === false
1257-
|| isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === false
1257+
|| isset(Tokens::$emptyTokens[$tokens[$i][0]]) === false
12581258
) {
12591259
break;
12601260
}
@@ -1284,7 +1284,7 @@ protected function tokenize($string)
12841284
$tokenType = $tokens[$i];
12851285
}
12861286

1287-
if (isset(Util\Tokens::$emptyTokens[$tokenType]) === true) {
1287+
if (isset(Tokens::$emptyTokens[$tokenType]) === true) {
12881288
continue;
12891289
}
12901290

@@ -1338,7 +1338,7 @@ protected function tokenize($string)
13381338
$newStackPtr++;
13391339

13401340
if (PHP_CODESNIFFER_VERBOSITY > 1 && $type !== T_READONLY) {
1341-
echo "\t\t* token $stackPtr changed from $type to T_READONLY".PHP_EOL;
1341+
Common::printStatusMessage("* token $stackPtr changed from $type to T_READONLY", 2);
13421342
}
13431343
} else {
13441344
$finalTokens[$newStackPtr] = [
@@ -1349,7 +1349,7 @@ protected function tokenize($string)
13491349
$newStackPtr++;
13501350

13511351
if (PHP_CODESNIFFER_VERBOSITY > 1 && $type !== T_STRING) {
1352-
echo "\t\t* token $stackPtr changed from $type to T_STRING".PHP_EOL;
1352+
Common::printStatusMessage("* token $stackPtr changed from $type to T_STRING", 2);
13531353
}
13541354
}//end if
13551355

tests/Core/Tokenizer/BackfillReadonlyTest.inc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ namespace My\Readonly\Collection;
8888
$var = readonly($a, $b);
8989
/* testReadonlyAsNamespacedFunctionCall */
9090
$var = My\NS\readonly($a, $b);
91-
/* testReadonlyAsNamespaceRelativeFunctionCall */
92-
$var = namespace\ReadOnly($a, $b);
9391
/* testReadonlyAsMethodCall */
9492
$var = $obj->readonly($a, $b);
9593
/* testReadonlyAsNullsafeMethodCall */

tests/Core/Tokenizer/BackfillReadonlyTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,11 +264,7 @@ public function dataNotReadonly()
264264
],
265265
[
266266
'/* testReadonlyAsNamespacedFunctionCall */',
267-
'readonly',
268-
],
269-
[
270-
'/* testReadonlyAsNamespaceRelativeFunctionCall */',
271-
'ReadOnly',
267+
'My\NS\readonly',
272268
],
273269
[
274270
'/* testReadonlyAsMethodCall */',

0 commit comments

Comments
 (0)