diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 03faf9c96e445..c56c9a68d7814 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6109,6 +6109,11 @@ static void zend_compile_declare(zend_ast *ast) /* {{{ */ zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must be " "the very first statement in the script"); } + + if (ast->child[1] != NULL) { + zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must not " + "use block mode"); + } } else if (zend_string_equals_literal_ci(name, "strict_types")) { zval value_zv; diff --git a/ext/mbstring/tests/zend_multibyte-11.phpt b/ext/mbstring/tests/zend_multibyte-11.phpt index bec2c482d6594..5f9d1a82b4be8 100644 --- a/ext/mbstring/tests/zend_multibyte-11.phpt +++ b/ext/mbstring/tests/zend_multibyte-11.phpt @@ -12,4 +12,4 @@ declare(encoding="ISO-8859-15") { } ?> --EXPECTF-- -Fatal error: Encoding declaration pragma must be the very first statement in the script in %s on line %d +Fatal error: Encoding declaration pragma must not use block mode in %s on line %d diff --git a/ext/mbstring/tests/zend_multibyte-15.phpt b/ext/mbstring/tests/zend_multibyte-15.phpt index bcf4ebe59d8ed..030869e0c5679 100644 --- a/ext/mbstring/tests/zend_multibyte-15.phpt +++ b/ext/mbstring/tests/zend_multibyte-15.phpt @@ -13,6 +13,5 @@ declare(encoding="UTF-8") { echo "ok\n"; } ?> ---EXPECT-- -ok -ok +--EXPECTF-- +Fatal error: Encoding declaration pragma must not use block mode in %s on line %d diff --git a/ext/mbstring/tests/zend_multibyte-16.phpt b/ext/mbstring/tests/zend_multibyte-16.phpt index ed02f6895b18d..d560fdcaa9659 100644 --- a/ext/mbstring/tests/zend_multibyte-16.phpt +++ b/ext/mbstring/tests/zend_multibyte-16.phpt @@ -11,6 +11,5 @@ declare(encoding="ISO-8859-15") { } echo "ok\n"; ?> ---EXPECT-- -ok -ok +--EXPECTF-- +Fatal error: Encoding declaration pragma must not use block mode in %s on line %d