mirror of
https://github.com/php/php-src.git
synced 2026-10-28 17:56:50 +08:00
* ext/bz2: applied fixers to improve test robustness * ext/calendar: applied fixers to improve test robustness * ext/exif: applied fixers to improve test robustness * ext/fileinfo: applied fixers to improve test robustness * ext/filter: applied fixers to improve test robustness * ext/ftp: applied fixers to improve test robustness * ext/hash: applied fixers to improve test robustness * ext/iconv: applied fixers to improve test robustness * ext/ldap: applied fixers to improve test robustness * ext/pcre: applied fixers to improve test robustness * ext/posix: applied fixers to improve test robustness * ext/readline: applied fixers to improve test robustness * ext/shmop: applied fixers to improve test robustness * ext/snmp: applied fixers to improve test robustness * ext/sodium: applied fixers to improve test robustness * ext/sqlite3: applied fixers to improve test robustness * ext/sysvmsg: applied fixers to improve test robustness * ext/sysvsem: applied fixers to improve test robustness * ext/sysvshm: applied fixers to improve test robustness * ext/tidy: applied fixers to improve test robustness * ext/tokenizer: applied fixers to improve test robustness * ext/zend_test: applied fixers to improve test robustness * ext/zlib: applied fixers to improve test robustness
67 lines
1.2 KiB
PHP
67 lines
1.2 KiB
PHP
--TEST--
|
|
Parse errors during token_get_all()
|
|
--EXTENSIONS--
|
|
tokenizer
|
|
--FILE--
|
|
<?php
|
|
|
|
function test_parse_error($code) {
|
|
try {
|
|
var_dump(token_get_all($code, TOKEN_PARSE));
|
|
} catch (ParseError $e) {
|
|
echo $e::class, ': ', $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);');
|
|
test_parse_error('<?php var_dump("\u{xyz}");');
|
|
test_parse_error('<?php var_dump("\u{ffffff}");');
|
|
test_parse_error('<?php var_dump(078 + 078);');
|
|
|
|
?>
|
|
--EXPECT--
|
|
ParseError: Invalid numeric literal
|
|
T_OPEN_TAG (<?php )
|
|
T_STRING (var_dump)
|
|
(
|
|
T_LNUMBER (078)
|
|
)
|
|
;
|
|
|
|
ParseError: Invalid UTF-8 codepoint escape sequence
|
|
T_OPEN_TAG (<?php )
|
|
T_STRING (var_dump)
|
|
(
|
|
T_CONSTANT_ENCAPSED_STRING ("\u{xyz}")
|
|
)
|
|
;
|
|
|
|
ParseError: Invalid UTF-8 codepoint escape sequence: Codepoint too large
|
|
T_OPEN_TAG (<?php )
|
|
T_STRING (var_dump)
|
|
(
|
|
T_CONSTANT_ENCAPSED_STRING ("\u{ffffff}")
|
|
)
|
|
;
|
|
|
|
ParseError: Invalid numeric literal
|
|
T_OPEN_TAG (<?php )
|
|
T_STRING (var_dump)
|
|
(
|
|
T_LNUMBER (078)
|
|
T_WHITESPACE ( )
|
|
+
|
|
T_WHITESPACE ( )
|
|
T_LNUMBER (078)
|
|
)
|
|
;
|