Skip to content

Commit

Permalink
Merge branch 'feature/3609-bugfix-context-sensitive-keyword-empty' of h…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Jun 13, 2022
2 parents a2cd51b + 5f78900 commit 3726154
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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

0 comments on commit 3726154

Please sign in to comment.