Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenizer/PHP: bug fix in improved context sensitive keyword support #3610

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Util/Tokens.php
Expand Up @@ -687,6 +687,7 @@ final class Tokens
T_ECHO => T_ECHO,
T_ELSE => T_ELSE,
T_ELSEIF => T_ELSEIF,
T_EMPTY => T_EMPTY,
T_ENDDECLARE => T_ENDDECLARE,
T_ENDFOR => T_ENDFOR,
T_ENDFOREACH => T_ENDFOREACH,
Expand All @@ -712,6 +713,7 @@ final class Tokens
T_INSTANCEOF => T_INSTANCEOF,
T_INSTEADOF => T_INSTEADOF,
T_INTERFACE => T_INTERFACE,
T_ISSET => T_ISSET,
T_LIST => T_LIST,
T_LOGICAL_AND => T_LOGICAL_AND,
T_LOGICAL_OR => T_LOGICAL_OR,
Expand All @@ -732,6 +734,7 @@ final class Tokens
T_THROW => T_THROW,
T_TRAIT => T_TRAIT,
T_TRY => T_TRY,
T_UNSET => T_UNSET,
T_USE => T_USE,
T_VAR => T_VAR,
T_WHILE => T_WHILE,
Expand Down
9 changes: 8 additions & 1 deletion tests/Core/Tokenizer/ContextSensitiveKeywordsTest.inc
Expand Up @@ -22,6 +22,7 @@ class ContextSensitiveKeywords
const /* testEcho */ ECHO = 'ECHO';
const /* testElse */ ELSE = 'ELSE';
const /* testElseIf */ ELSEIF = 'ELSEIF';
const /* testEmpty */ EMPTY = 'EMPTY';
const /* testEndDeclare */ ENDDECLARE = 'ENDDECLARE';
const /* testEndFor */ ENDFOR = 'ENDFOR';
const /* testEndForeach */ ENDFOREACH = 'ENDFOREACH';
Expand All @@ -47,6 +48,7 @@ class ContextSensitiveKeywords
const /* testInstanceOf */ INSTANCEOF = 'INSTANCEOF';
const /* testInsteadOf */ INSTEADOF = 'INSTEADOF';
const /* testInterface */ INTERFACE = 'INTERFACE';
const /* testIsset */ ISSET = 'ISSET';
const /* testList */ LIST = 'LIST';
const /* testMatch */ MATCH = 'MATCH';
const /* testNamespace */ NAMESPACE = 'NAMESPACE';
Expand All @@ -66,6 +68,7 @@ class ContextSensitiveKeywords
const /* testThrows */ THROW = 'THROW';
const /* testTrait */ TRAIT = 'TRAIT';
const /* testTry */ TRY = 'TRY';
const /* testUnset */ UNSET = 'UNSET';
const /* testUse */ USE = 'USE';
const /* testVar */ VAR = 'VAR';
const /* testWhile */ WHILE = 'WHILE';
Expand Down Expand Up @@ -121,7 +124,7 @@ $object = /* testNewIsKeyword */ new SomeClass();
$object /* testInstanceOfIsKeyword */ instanceof SomeClass;
$copy = /* testCloneIsKeyword */ clone $object;

/* testIfIsKeyword */ if (true):
/* testIfIsKeyword */ if (/* testEmptyIsKeyword */ empty($a)):
/* testElseIfIsKeyword */ elseif (false):
/* testElseIsKeyword */ else:
/* testEndIfIsKeyword */ endif;
Expand Down Expand Up @@ -170,6 +173,10 @@ die($foo);
eval('<?php echo 5;');
/* testExitIsKeyword */
exit;
/* testIssetIsKeyword */
$a = isset($a);
/* testUnsetIsKeyword */
unset($a);

/* testIncludeIsKeyword */
include 'file.php';
Expand Down
15 changes: 15 additions & 0 deletions tests/Core/Tokenizer/ContextSensitiveKeywordsTest.php
Expand Up @@ -65,6 +65,7 @@ public function dataStrings()
['/* testEcho */'],
['/* testElse */'],
['/* testElseIf */'],
['/* testEmpty */'],
['/* testEndDeclare */'],
['/* testEndFor */'],
['/* testEndForeach */'],
Expand All @@ -90,6 +91,7 @@ public function dataStrings()
['/* testInstanceOf */'],
['/* testInsteadOf */'],
['/* testInterface */'],
['/* testIsset */'],
['/* testList */'],
['/* testMatch */'],
['/* testNamespace */'],
Expand All @@ -109,6 +111,7 @@ public function dataStrings()
['/* testThrows */'],
['/* testTrait */'],
['/* testTry */'],
['/* testUnset */'],
['/* testUse */'],
['/* testVar */'],
['/* testWhile */'],
Expand Down Expand Up @@ -278,6 +281,10 @@ public function dataKeywords()
'/* testIfIsKeyword */',
'T_IF',
],
[
'/* testEmptyIsKeyword */',
'T_EMPTY',
],
[
'/* testElseIfIsKeyword */',
'T_ELSEIF',
Expand Down Expand Up @@ -388,6 +395,14 @@ public function dataKeywords()
'/* testExitIsKeyword */',
'T_EXIT',
],
[
'/* testIssetIsKeyword */',
'T_ISSET',
],
[
'/* testUnsetIsKeyword */',
'T_UNSET',
],

[
'/* testIncludeIsKeyword */',
Expand Down