Skip to content

Tokenizer: isset/unset/empty/eval/exit/die now contain parenthesis information #1014

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Util/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ final class Tokens
T_CATCH => T_CATCH,
T_DECLARE => T_DECLARE,
T_MATCH => T_MATCH,
T_ISSET => T_ISSET,
T_EMPTY => T_EMPTY,
T_UNSET => T_UNSET,
T_EVAL => T_EVAL,
T_EXIT => T_EXIT,
];

/**
Expand Down
17 changes: 11 additions & 6 deletions tests/Core/Tokenizers/Tokenizer/CreateTokenMapParenthesesTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -84,24 +84,29 @@ $a = ($b + $c/* testArbitraryParenthesesCloser */);
/* testFunctionCallParenthesesOpener */
do_something($b + $c, $d, false /* testFunctionCallParenthesesCloser */);

/* testIssetParenthesesOpener */
/* testIssetParenthesesOwner */
$set = isset($b, $c/* testIssetParenthesesCloser */);

/* testEmptyParenthesesOpener */
/* testEmptyParenthesesOwner */
$empty = empty($b /* testEmptyParenthesesCloser */);

/* testUnsetParenthesesOpener */
/* testUnsetParenthesesOwner */
unset ($b, $c /* testUnsetParenthesesCloser */);

/* testEvalParenthesesOpener */
/* testEvalParenthesesOwner */
$eval = eval("\$str = \"$str\";"/* testEvalParenthesesCloser */);

/* testExitParenthesesOpener */
/* testExitParenthesesOwner */
exit ( 101 /* testExitParenthesesCloser */);

/* testDieParenthesesOpener */
/* testDieParenthesesOwner */
die ('oopsie' /* testDieParenthesesCloser */);

/* testExitNoParentheses */
exit;

/* testDieNoParentheses */
die;

/*
* All together now, let's make things a little more interesting....
Expand Down
50 changes: 32 additions & 18 deletions tests/Core/Tokenizers/Tokenizer/CreateTokenMapParenthesesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,30 @@ public static function dataParenthesesWithOwner()
'testMarker' => '/* testAnonClassParenthesesOwner */',
'tokenCode' => T_ANON_CLASS,
],
'isset' => [
'testMarker' => '/* testIssetParenthesesOwner */',
'tokenCode' => T_ISSET,
],
'empty' => [
'testMarker' => '/* testEmptyParenthesesOwner */',
'tokenCode' => T_EMPTY,
],
'unset' => [
'testMarker' => '/* testUnsetParenthesesOwner */',
'tokenCode' => T_UNSET,
],
'eval' => [
'testMarker' => '/* testEvalParenthesesOwner */',
'tokenCode' => T_EVAL,
],
'exit' => [
'testMarker' => '/* testExitParenthesesOwner */',
'tokenCode' => T_EXIT,
],
'die' => [
'testMarker' => '/* testDieParenthesesOwner */',
'tokenCode' => T_EXIT,
],

'if - nested outer' => [
'testMarker' => '/* testNestedOuterIfParenthesesOwner */',
Expand Down Expand Up @@ -233,24 +257,6 @@ public static function dataParenthesesWithoutOwner()
'function call' => [
'testMarker' => '/* testFunctionCallParenthesesOpener */',
],
'isset' => [
'testMarker' => '/* testIssetParenthesesOpener */',
],
'empty' => [
'testMarker' => '/* testEmptyParenthesesOpener */',
],
'unset' => [
'testMarker' => '/* testUnsetParenthesesOpener */',
],
'eval' => [
'testMarker' => '/* testEvalParenthesesOpener */',
],
'exit' => [
'testMarker' => '/* testExitParenthesesOpener */',
],
'die' => [
'testMarker' => '/* testDieParenthesesOpener */',
],
'function call - nested 1' => [
'testMarker' => '/* testNestedFunctionCallAParenthesesOpener */',
],
Expand Down Expand Up @@ -305,6 +311,14 @@ public static function dataParenthesesOwnerWithoutParentheses()
'testMarker' => '/* testAnonClassNoParentheses */',
'tokenCode' => T_ANON_CLASS,
],
'exit without parentheses' => [
'testMarker' => '/* testExitNoParentheses */',
'tokenCode' => T_EXIT,
],
'die without parentheses' => [
'testMarker' => '/* testDieNoParentheses */',
'tokenCode' => T_EXIT,
],
];

}//end dataParenthesesOwnerWithoutParentheses()
Expand Down