com php-src: Replace "unexpected character" warning with ParseError: UPGRADING Zend/tests/warning_during_heredoc_scan_ahead .phpt
Zend/zend_language_scanner.l ext/tokenizer/te sts/bad_character.phpt tests/lang/bug71897.ph pt
| From: | Nikita Popov | Date: | Fri, 04 Oct 2019 09:28:58 +0000 |
| Subject: | com php-src: Replace "unexpected character" warning with ParseError: UPGRADING Zend/tests/warning_during_heredoc_scan_ahead .phpt Zend/zend_language_scanner.l ext/tokenizer/te sts/bad_character.phpt tests/lang/bug71897.ph pt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-108721@lists.php.net to get a copy of this message | ||
Commit: d44cf9b539c5dfbd3ff0295bac25165e79214e09
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 2 Oct 2019 12:24:11 +0200
Parents: 11d139625f328873a348cc11df21bdb59bbeaba4
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d44cf9b539c5dfbd3ff0295bac25165e79214e09
Log:
Replace "unexpected character" warning with ParseError
Closes GH-4767.
Changed paths:
M UPGRADING
M Zend/tests/warning_during_heredoc_scan_ahead.phpt
M Zend/zend_language_scanner.l
M ext/tokenizer/tests/bad_character.phpt
M tests/lang/bug71897.phpt
Diff:
diff --git a/UPGRADING b/UPGRADING
index 302daa57ec7..ea18a5052a6 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -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
diff --git a/Zend/tests/warning_during_heredoc_scan_ahead.phpt
b/Zend/tests/warning_during_heredoc_scan_ahead.phpt
index 099d1c087ff..125c392d9d0 100644
--- a/Zend/tests/warning_during_heredoc_scan_ahead.phpt
+++ b/Zend/tests/warning_during_heredoc_scan_ahead.phpt
@@ -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
diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l
index 27fb296d585...5ca29ee3be7 100644
--- a/Zend/zend_language_scanner.l
+++ b/Zend/zend_language_scanner.l
@@ -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);
}
*/
diff --git a/ext/tokenizer/tests/bad_character.phpt b/ext/tokenizer/tests/bad_character.phpt
index 87f0179004e..5456530ca39 100644
--- a/ext/tokenizer/tests/bad_character.phpt
+++ b/ext/tokenizer/tests/bad_character..phpt
@@ -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
diff --git a/tests/lang/bug71897.phpt b/tests/lang/bug71897.phpt
index 5864b1dece0..b2c41a359f5 100644
--- a/tests/lang/bug71897.phpt
+++ b/tests/lang/bug71897.phpt
@@ -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