Skip to content

Commit

Permalink
Fix up "Fix mis-identification of 'readonly' keyword"
Browse files Browse the repository at this point in the history
... for changes between PHPCS 3.x vs 4.x.
  • Loading branch information
jrfnl committed Nov 9, 2023
1 parent 674b27a commit aa9bd2b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ protected function tokenize($string)
// Get the next non-whitespace token.
for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
if (is_array($tokens[$i]) === false
|| isset(Util\Tokens::$emptyTokens[$tokens[$i][0]]) === false
|| isset(Tokens::$emptyTokens[$tokens[$i][0]]) === false
) {
break;
}
Expand Down Expand Up @@ -1284,7 +1284,7 @@ protected function tokenize($string)
$tokenType = $tokens[$i];
}

if (isset(Util\Tokens::$emptyTokens[$tokenType]) === true) {
if (isset(Tokens::$emptyTokens[$tokenType]) === true) {
continue;
}

Expand Down Expand Up @@ -1338,7 +1338,7 @@ protected function tokenize($string)
$newStackPtr++;

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

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

Expand Down
2 changes: 0 additions & 2 deletions tests/Core/Tokenizer/BackfillReadonlyTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ namespace My\Readonly\Collection;
$var = readonly($a, $b);
/* testReadonlyAsNamespacedFunctionCall */
$var = My\NS\readonly($a, $b);
/* testReadonlyAsNamespaceRelativeFunctionCall */
$var = namespace\ReadOnly($a, $b);
/* testReadonlyAsMethodCall */
$var = $obj->readonly($a, $b);
/* testReadonlyAsNullsafeMethodCall */
Expand Down
6 changes: 1 addition & 5 deletions tests/Core/Tokenizer/BackfillReadonlyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,7 @@ public function dataNotReadonly()
],
[
'/* testReadonlyAsNamespacedFunctionCall */',
'readonly',
],
[
'/* testReadonlyAsNamespaceRelativeFunctionCall */',
'ReadOnly',
'My\NS\readonly',
],
[
'/* testReadonlyAsMethodCall */',
Expand Down

0 comments on commit aa9bd2b

Please sign in to comment.