Skip to content

Commit

Permalink
The T_ARRAY_HINT token has been deprectated and will be removed in ve…
Browse files Browse the repository at this point in the history
…rsion 4 (ref #1527)
  • Loading branch information
gsherwood committed Apr 18, 2018
1 parent b0cadcd commit 4cb6b53
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
--- For example, element key="print" value="echo"
-- Thanks to Michał Bundyra for the patch

- The T_ARRAY_HINT token has been deprectated and will be removed in version 4
-- The token was used to ensure array type hints were not tokenized as T_ARRAY, but no other type hints were given a special token
-- Array type hints now use the standard T_STRING token instead
-- Sniffs referencing this token type will continue to run without error until version 4, but will not find any T_ARRAY_HINT tokens

- Config values set using --runtime-set now override any config values set in rulesets or the CodeSniffer.conf file
- You can now apply include-pattern rules to individual message codes in a ruleset like you can with exclude-pattern rules
-- Previously, include-pattern rules only applied to entire sniffs
Expand Down
1 change: 0 additions & 1 deletion src/Files/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@ public function getMethodParameters($stackPtr)
case T_ELLIPSIS:
$variableLength = true;
break;
case T_ARRAY_HINT:
case T_CALLABLE:
$typeHint .= $this->tokens[$i]['content'];
break;
Expand Down
1 change: 0 additions & 1 deletion src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function register()
T_HALT_COMPILER,
T_ABSTRACT,
T_ARRAY,
T_ARRAY_HINT,
T_AS,
T_BREAK,
T_CALLABLE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const array()
for ($var as $var) { exit; }
if ($a and $b or $c xor $d) { die; } elseif { } else
goto a;
function (array $a) {}
function (Array $a) {}
const PRIVATE;
HttpStatus::CONTINUE;
function ($f) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function getErrorList()
13 => 3,
14 => 7,
15 => 1,
16 => 1,
19 => 1,
20 => 1,
21 => 1,
Expand Down
8 changes: 3 additions & 5 deletions src/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ class PHP extends Tokenizer
T_SR => 2,
T_SL_EQUAL => 3,
T_SR_EQUAL => 3,
T_ARRAY_HINT => 5,
T_GREATER_THAN => 1,
T_LESS_THAN => 1,
T_BOOLEAN_NOT => 1,
Expand Down Expand Up @@ -1073,7 +1072,6 @@ protected function tokenize($string)
$allowed = [
T_STRING => T_STRING,
T_ARRAY => T_ARRAY,
T_ARRAY_HINT => T_ARRAY_HINT,
T_CALLABLE => T_CALLABLE,
T_SELF => T_SELF,
T_PARENT => T_PARENT,
Expand Down Expand Up @@ -1433,14 +1431,14 @@ protected function tokenize($string)
// This is a special condition for T_ARRAY tokens used for
// type hinting function arguments as being arrays. We want to keep
// the parenthesis map clean, so let's tag these tokens as
// T_ARRAY_HINT.
// T_STRING.
if ($newToken['code'] === T_ARRAY) {
for ($i = $stackPtr; $i < $numTokens; $i++) {
if ($tokens[$i] === '(') {
break;
} else if ($tokens[$i][0] === T_VARIABLE) {
$newToken['code'] = T_ARRAY_HINT;
$newToken['type'] = 'T_ARRAY_HINT';
$newToken['code'] = T_STRING;
$newToken['type'] = 'T_STRING';
break;
}
}
Expand Down

0 comments on commit 4cb6b53

Please sign in to comment.