Replace "unexpected character" warning with ParseError

Closes GH-4767.
This commit is contained in:
Nikita Popov 2019-10-02 12:24:11 +02:00
parent 11d139625f
commit d44cf9b539
5 changed files with 7 additions and 22 deletions

View file

@ -109,6 +109,9 @@ PHP 8.0 UPGRADE NOTES
* Attempting to read an out-of-bounds string offset.
RFC: https://wiki.php.net/rfc/engine_warnings
. Unexpected characters in source files (such as null bytes outside of
strings) will now result in a ParseError exception instead of a compile
warning.
- COM:
. Removed the ability to import case-insensitive constants from type

View file

@ -4,15 +4,12 @@ No warnings should be thrown during heredoc scan-ahead
<?php
<<<TEST
${x}
\400
${/*}
TEST;
?>
--EXPECTF--
Warning: Unexpected character in input: '' (ASCII=1) state=0 in %s on line %d
Warning: Octal escape sequence overflow \400 is greater than \377 in %s on line %d
Warning: Unterminated comment starting line %d in %s on line %d

View file

@ -2834,14 +2834,7 @@ nowdoc_scan_done:
RETURN_TOKEN(END);
}
if (!SCNG(heredoc_scan_ahead)) {
zend_error(E_COMPILE_WARNING, "Unexpected character in input: '%c' (ASCII=%d) state=%d", yytext[0], yytext[0], YYSTATE);
}
if (PARSER_MODE()) {
goto restart;
} else {
RETURN_TOKEN(T_BAD_CHARACTER);
}
RETURN_TOKEN(T_BAD_CHARACTER);
}
*/

View file

@ -19,27 +19,21 @@ foreach ($codes as $code) {
echo $token, "\n";
}
}
echo "\n";
}
?>
--EXPECTF--
Warning: Unexpected character in input: ' in %s on line %d
--EXPECT--
T_OPEN_TAG 6
T_BAD_CHARACTER 1
T_WHITESPACE 1
T_STRING 3
Warning: Unexpected character in input: '%s' (ASCII=1) state=0 in %s on line %d
T_OPEN_TAG 6
T_BAD_CHARACTER 1
T_WHITESPACE 1
T_STRING 3
Warning: Unexpected character in input: '%s' (ASCII=1) state=0 in %s on line %d
Warning: Unexpected character in input: '%s' (ASCII=2) state=0 in %s on line %d
Warning: Unexpected character in input: '%s' (ASCII=3) state=0 in %s on line %d
T_OPEN_TAG 6
T_BAD_CHARACTER 1
T_BAD_CHARACTER 1

View file

@ -10,6 +10,4 @@ eval("
?>
--EXPECTF--
Warning: Unexpected character in input: '%s' (ASCII=127) state=0 in %s(%d) : eval()'d code on line %d
Parse error: syntax error, unexpected 'b' (T_STRING) in %s(%d) : eval()'d code on line %d
Parse error: syntax error, unexpected '%s' (T_BAD_CHARACTER) in %s on line %d