diff --git a/Zend/tests/gh19719.phpt b/Zend/tests/gh19719.phpt new file mode 100644 index 0000000000000..715e847846fe1 --- /dev/null +++ b/Zend/tests/gh19719.phpt @@ -0,0 +1,21 @@ +--TEST-- +GH-19719: Allow empty expressions before declare(strict_types) +--FILE-- + +getMessage(), "\n"; +} + +?> +--EXPECTF-- +takesInt(): Argument #1 ($x) must be of type int, string given, called in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ad735c41acaff..f43fdd7b31827 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -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"); }