Skip to content

zend_ast: Preserve heredocs in zend_ast_export() #18690

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

xepozz
Copy link
Contributor

@xepozz xepozz commented May 28, 2025

now just with HEREDOC name

@xepozz xepozz marked this pull request as draft May 28, 2025 18:10
zend_ast_export_str(str, Z_STR_P(zv));
smart_str_appendc(str, '\'');
if (ast->attr & ZEND_NAME_HEREDOC) {
smart_str_appends(str, "<<<HEREDOC\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
smart_str_appends(str, "<<<HEREDOC\n");
smart_str_appends(str, "<<<'EOD'\n");

Comment on lines +9 to +11
<<<HTML
val inside
HTML
Copy link
Member

Choose a reason for hiding this comment

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

What would happen if:

  • The string contains a line HEREDOC?
  • The string contains special characters that would be escaped by zend_ast_export_str()?

Is it guaranteed that the output is valid PHP in all cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll cover these with tests, thanks.

@TimWolla TimWolla changed the title fix: dump heredoc tags zend_ast: Preserve heredocs in zend_ast_export() May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants