summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRowan Tommins <git@rwec.co.uk>2020-06-11 20:56:22 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-07-13 11:07:40 +0200
commit55a15f32ced0bd2467e6dec0c1287a4f11b1852f (patch)
treea88ec4ac9a7c7480fa877b8248cfdfb5c178ea00 /tests
parentd4fdf79add800b4c529e6a31f2a0ff665b8b97ce (diff)
downloadphp-git-55a15f32ced0bd2467e6dec0c1287a4f11b1852f.tar.gz
Improve output of tokens in Parse Errors
Currently, unexpected tokens in the parser are shown as the text found, plus the internal token name, including the notorious "unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM)". This commit replaces that with a more user-friendly format, with two main types of token: * Tokens which always represent the same text are shown like 'unexpected token "::"' and 'expected "::"' * Tokens which have variable text are given a user-friendly name, and show like 'unexpected identifier "foo"', and 'expected identifer'. A few tokens have special cases: * unexpected token """ -> unexpected double-quote mark * unexpected quoted string "'foo'" -> unexpected single-quoted string "foo" * unexpected quoted string ""foo"" -> unexpected double-quoted string "foo" * unexpected illegal character "_" -> unexpected character 0xNN (where _ is almost certainly a control character, and NN is the hexadecimal value of the byte) The \ token has a special case in the implementation just to stop bison making a mess of escaping it and it coming out as \\
Diffstat (limited to 'tests')
-rw-r--r--tests/lang/bug21820.phpt2
-rw-r--r--tests/lang/bug71897.phpt2
2 files changed, 2 insertions, 2 deletions
diff --git a/tests/lang/bug21820.phpt b/tests/lang/bug21820.phpt
index cbf466eea7..ec213db00d 100644
--- a/tests/lang/bug21820.phpt
+++ b/tests/lang/bug21820.phpt
@@ -10,4 +10,4 @@ echo "$arr['foo']";
?>
--EXPECTF--
-Parse error: %s error, %s(T_STRING)%s(T_VARIABLE)%s(T_NUM_STRING)%sin %sbug21820.php on line %d
+Parse error: %s error, %sidentifier%svariable%snumber%sin %sbug21820.php on line %d
diff --git a/tests/lang/bug71897.phpt b/tests/lang/bug71897.phpt
index b2c41a359f..9cbf17a64c 100644
--- a/tests/lang/bug71897.phpt
+++ b/tests/lang/bug71897.phpt
@@ -10,4 +10,4 @@ eval("
?>
--EXPECTF--
-Parse error: syntax error, unexpected '%s' (T_BAD_CHARACTER) in %s on line %d
+Parse error: syntax error, unexpected character 0x7F in %s on line %d