Skip to content

Commit 268d6ad

Browse files
authored
Merge pull request #1014 from PHPCSStandards/phpcs-4.0/feature/23-tokenizer-isset-unset-empty-eval-exit-parentheses-owner
Tokenizer: isset/unset/empty/eval/exit/die now contain parenthesis information
2 parents cd6fe9f + 95f8443 commit 268d6ad

File tree

3 files changed

+48
-24
lines changed

3 files changed

+48
-24
lines changed

src/Util/Tokens.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,11 @@ final class Tokens
369369
T_CATCH => T_CATCH,
370370
T_DECLARE => T_DECLARE,
371371
T_MATCH => T_MATCH,
372+
T_ISSET => T_ISSET,
373+
T_EMPTY => T_EMPTY,
374+
T_UNSET => T_UNSET,
375+
T_EVAL => T_EVAL,
376+
T_EXIT => T_EXIT,
372377
];
373378

374379
/**

tests/Core/Tokenizers/Tokenizer/CreateTokenMapParenthesesTest.inc

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,29 @@ $a = ($b + $c/* testArbitraryParenthesesCloser */);
8484
/* testFunctionCallParenthesesOpener */
8585
do_something($b + $c, $d, false /* testFunctionCallParenthesesCloser */);
8686

87-
/* testIssetParenthesesOpener */
87+
/* testIssetParenthesesOwner */
8888
$set = isset($b, $c/* testIssetParenthesesCloser */);
8989

90-
/* testEmptyParenthesesOpener */
90+
/* testEmptyParenthesesOwner */
9191
$empty = empty($b /* testEmptyParenthesesCloser */);
9292

93-
/* testUnsetParenthesesOpener */
93+
/* testUnsetParenthesesOwner */
9494
unset ($b, $c /* testUnsetParenthesesCloser */);
9595

96-
/* testEvalParenthesesOpener */
96+
/* testEvalParenthesesOwner */
9797
$eval = eval("\$str = \"$str\";"/* testEvalParenthesesCloser */);
9898

99-
/* testExitParenthesesOpener */
99+
/* testExitParenthesesOwner */
100100
exit ( 101 /* testExitParenthesesCloser */);
101101

102-
/* testDieParenthesesOpener */
102+
/* testDieParenthesesOwner */
103103
die ('oopsie' /* testDieParenthesesCloser */);
104104

105+
/* testExitNoParentheses */
106+
exit;
107+
108+
/* testDieNoParentheses */
109+
die;
105110

106111
/*
107112
* All together now, let's make things a little more interesting....

tests/Core/Tokenizers/Tokenizer/CreateTokenMapParenthesesTest.php

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,30 @@ public static function dataParenthesesWithOwner()
151151
'testMarker' => '/* testAnonClassParenthesesOwner */',
152152
'tokenCode' => T_ANON_CLASS,
153153
],
154+
'isset' => [
155+
'testMarker' => '/* testIssetParenthesesOwner */',
156+
'tokenCode' => T_ISSET,
157+
],
158+
'empty' => [
159+
'testMarker' => '/* testEmptyParenthesesOwner */',
160+
'tokenCode' => T_EMPTY,
161+
],
162+
'unset' => [
163+
'testMarker' => '/* testUnsetParenthesesOwner */',
164+
'tokenCode' => T_UNSET,
165+
],
166+
'eval' => [
167+
'testMarker' => '/* testEvalParenthesesOwner */',
168+
'tokenCode' => T_EVAL,
169+
],
170+
'exit' => [
171+
'testMarker' => '/* testExitParenthesesOwner */',
172+
'tokenCode' => T_EXIT,
173+
],
174+
'die' => [
175+
'testMarker' => '/* testDieParenthesesOwner */',
176+
'tokenCode' => T_EXIT,
177+
],
154178

155179
'if - nested outer' => [
156180
'testMarker' => '/* testNestedOuterIfParenthesesOwner */',
@@ -237,24 +261,6 @@ public static function dataParenthesesWithoutOwner()
237261
'function call' => [
238262
'testMarker' => '/* testFunctionCallParenthesesOpener */',
239263
],
240-
'isset' => [
241-
'testMarker' => '/* testIssetParenthesesOpener */',
242-
],
243-
'empty' => [
244-
'testMarker' => '/* testEmptyParenthesesOpener */',
245-
],
246-
'unset' => [
247-
'testMarker' => '/* testUnsetParenthesesOpener */',
248-
],
249-
'eval' => [
250-
'testMarker' => '/* testEvalParenthesesOpener */',
251-
],
252-
'exit' => [
253-
'testMarker' => '/* testExitParenthesesOpener */',
254-
],
255-
'die' => [
256-
'testMarker' => '/* testDieParenthesesOpener */',
257-
],
258264
'function call - nested 1' => [
259265
'testMarker' => '/* testNestedFunctionCallAParenthesesOpener */',
260266
],
@@ -306,6 +312,14 @@ public static function dataParenthesesOwnerWithoutParentheses()
306312
'testMarker' => '/* testAnonClassNoParentheses */',
307313
'tokenCode' => T_ANON_CLASS,
308314
],
315+
'exit without parentheses' => [
316+
'testMarker' => '/* testExitNoParentheses */',
317+
'tokenCode' => T_EXIT,
318+
],
319+
'die without parentheses' => [
320+
'testMarker' => '/* testDieNoParentheses */',
321+
'tokenCode' => T_EXIT,
322+
],
309323
];
310324

311325
}//end dataParenthesesOwnerWithoutParentheses()

0 commit comments

Comments
 (0)