diff options
author | Nikita Popov <nikic@php.net> | 2015-07-09 19:10:06 +0200 |
---|---|---|
committer | Nikita Popov <nikic@php.net> | 2015-07-09 19:11:48 +0200 |
commit | d91aad5966f01259f0e1a431a754d917807761b5 (patch) | |
tree | 61c8a47a8df510506e09730234d5d9c65fb59777 /ext/tokenizer/tests | |
parent | 8abc3022b070a378dc31f9727ddece78557ca7a8 (diff) | |
download | php-git-d91aad5966f01259f0e1a431a754d917807761b5.tar.gz |
Fix bug #69430
Don't throw from token_get_all() unless TOKEN_PARSE is used. Errors
are reported as T_ERROR tokens.
Diffstat (limited to 'ext/tokenizer/tests')
-rw-r--r-- | ext/tokenizer/tests/parse_errors.phpt | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/ext/tokenizer/tests/parse_errors.phpt b/ext/tokenizer/tests/parse_errors.phpt index bfa6e07ac4..3f376e0f9a 100644 --- a/ext/tokenizer/tests/parse_errors.phpt +++ b/ext/tokenizer/tests/parse_errors.phpt @@ -7,10 +7,19 @@ Parse errors during token_get_all() function test_parse_error($code) { try { - var_dump(token_get_all($code)); + var_dump(token_get_all($code, TOKEN_PARSE)); } catch (ParseError $e) { echo $e->getMessage(), "\n"; } + + foreach (token_get_all($code) as $token) { + if (is_array($token)) { + echo token_name($token[0]), " ($token[1])\n"; + } else { + echo "$token\n"; + } + } + echo "\n"; } test_parse_error('<?php var_dump(078);'); @@ -21,6 +30,37 @@ test_parse_error('<?php var_dump(078 + 078);'); ?> --EXPECT-- Invalid numeric literal +T_OPEN_TAG (<?php ) +T_STRING (var_dump) +( +T_ERROR (078) +) +; + Invalid UTF-8 codepoint escape sequence +T_OPEN_TAG (<?php ) +T_STRING (var_dump) +( +T_ERROR ("\u{xyz}") +) +; + Invalid UTF-8 codepoint escape sequence: Codepoint too large +T_OPEN_TAG (<?php ) +T_STRING (var_dump) +( +T_ERROR ("\u{ffffff}") +) +; + Invalid numeric literal +T_OPEN_TAG (<?php ) +T_STRING (var_dump) +( +T_ERROR (078) +T_WHITESPACE ( ) ++ +T_WHITESPACE ( ) +T_ERROR (078) +) +; |