Skip to content

Commit

Permalink
Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized
Browse files Browse the repository at this point in the history
I don't think this is related to PHP 5.6, but this was the best place to put the code.
  • Loading branch information
gsherwood committed Oct 4, 2016
1 parent f93682a commit 93f8bce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,6 @@ some
text
here
EOD;

if ($a && $a === Foo::VARIABLE && ($a === Foo::METHOD || $a === Foo::FUNCTION))
echo 'hi';
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,7 @@ text
here
EOD;
}

if ($a && $a === Foo::VARIABLE && ($a === Foo::METHOD || $a === Foo::FUNCTION)) {
echo 'hi';
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function getErrorList($testFile='InlineControlStructureUnitTest.inc')
168 => 1,
170 => 1,
178 => 1,
185 => 1,
);
break;
case 'InlineControlStructureUnitTest.js':
Expand Down
3 changes: 2 additions & 1 deletion CodeSniffer/Tokenizers/PHP.php
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,8 @@ public function tokenizeString($string, $eolChar='\n')

// This is a special case for the PHP 5.5 classname::class syntax
// where "class" should be T_STRING instead of T_CLASS.

This comment has been minimized.

Copy link
@aik099

aik099 Oct 4, 2016

Contributor

The comment now doesn't reflect function keyword usage.

if ($newToken['code'] === T_CLASS
if (($newToken['code'] === T_CLASS
|| $newToken['code'] === T_FUNCTION)
&& $finalTokens[($newStackPtr - 1)]['code'] === T_DOUBLE_COLON
) {
$newToken['code'] = T_STRING;
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Nikola Kovacs for the patch
- Fixed bug #1161 : Absolute report path is treated like a relative path if it also exists within the current directory
- Fixed bug #1170 : Javascript regular expression literal not recognized after comparison operator
- Fixed bug #1180 : Class constant named FUNCTION is incorrectly tokenized
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit 93f8bce

Please sign in to comment.