Skip to content

No longer allow block mode for declare(encoding) #9455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration pragma must not "
zend_error_noreturn(E_COMPILE_ERROR, "Encoding declaration must not "

I know that pragma is used in the current wording, but the strict_type one does not use this word, so it might make sense to change the wording to be consistent

"use block mode");
}
} else if (zend_string_equals_literal_ci(name, "strict_types")) {
zval value_zv;

Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/tests/zend_multibyte-11.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 2 additions & 3 deletions ext/mbstring/tests/zend_multibyte-15.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes no sense to test block mode thrice. Just change the test to not use block mode (or drop it if redundant).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, right! This was just to get CI green quickly. I'll update/fix this soonish.

5 changes: 2 additions & 3 deletions ext/mbstring/tests/zend_multibyte-16.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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