mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Allow empty statements before declare(strict_types)
Fixes GH-19719 Closes GH-19859
This commit is contained in:
committed by
Ilija Tovilo
parent
5c6f25bd64
commit
1f6ac30769
2
NEWS
2
NEWS
@@ -13,6 +13,8 @@ PHP NEWS
|
||||
using OPcache). (timwolla)
|
||||
. Fixed bug GH-19480 (error_log php.ini cannot be unset when open_basedir is
|
||||
configured). (nielsdos)
|
||||
. Fixed bug GH-19719 (Allow empty statements before declare(strict_types)).
|
||||
(nielsdos)
|
||||
|
||||
- Curl:
|
||||
. Fix cloning of CURLOPT_POSTFIELDS when using the clone operator instead
|
||||
|
||||
21
Zend/tests/gh19719.phpt
Normal file
21
Zend/tests/gh19719.phpt
Normal file
@@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
GH-19719: Allow empty expressions before declare(strict_types)
|
||||
--FILE--
|
||||
<?php
|
||||
// e.g some comments
|
||||
?>
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
function takesInt(int $x) {}
|
||||
|
||||
try {
|
||||
takesInt('42');
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
takesInt(): Argument #1 ($x) must be of type int, string given, called in %s on line %d
|
||||
@@ -7008,7 +7008,7 @@ static void zend_compile_declare(zend_ast *ast) /* {{{ */
|
||||
} else if (zend_string_equals_literal_ci(name, "strict_types")) {
|
||||
zval value_zv;
|
||||
|
||||
if (FAILURE == zend_is_first_statement(ast, /* allow_nop */ 0)) {
|
||||
if (FAILURE == zend_is_first_statement(ast, /* allow_nop */ true)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "strict_types declaration must be "
|
||||
"the very first statement in the script");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user