Skip to content

zend_ast: Fix AST export treating 0x7f as a valid name character - #25227

Open
jorgsowa wants to merge 1 commit into
php:PHP-8.6from
jorgsowa:fix-ast-export-del-in-names
Open

jorgsowa wants to merge 1 commit into
php:PHP-8.6from
jorgsowa:fix-ast-export-del-in-names

Conversation

@jorgsowa

@jorgsowa jorgsowa commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

zend_ast_valid_var_name() treated 0x7f as a name character, but unquoted identifiers haven't allowed it since PHP 7.1. As a result, names containing it were exported bare ($o->a\177, C::\177), which produces code that doesn't parse. They are now exported quoted ($o->{'a\177'}, C::{'\177'}).

Retargeted from PHP-8.4 to PHP-8.6. The invalid-name quoting from the earlier version of this PR is already in 8.6 through #22294. String interpolation in 8.6 always braces variables, so the encaps change, the ${expr} deprecation and the "{$a}->b" case don't apply.

@jorgsowa jorgsowa self-assigned this Nov 5, 2026
@jorgsowa

jorgsowa commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up of #25221

CC: @iliaal

Comment thread Zend/tests/assert/expect_015.phpt Resolved
@jorgsowa
jorgsowa force-pushed the fix-ast-export-del-in-names branch from ccb0638 to c1b2f3d Compare November 8, 2026 17:35
@jorgsowa
jorgsowa requested a review from iliaal November 8, 2026 17:37
@iliaal

iliaal commented Nov 9, 2026

Copy link
Copy Markdown
Member

The interpolation case is fixed. Separately, the same encaps condition still exports "{$a}->b" as "$a->b", which reparses as a property fetch.

@jorgsowa
jorgsowa changed the base branch from PHP-8.4 to PHP-8.6 November 12, 2026 15:18
@jorgsowa
jorgsowa force-pushed the fix-ast-export-del-in-names branch from c1b2f3d to e0d1a02 Compare November 12, 2026 15:19
@jorgsowa jorgsowa changed the title zend_ast: Fix ast export del in names, invalid variable and property names zend_ast: Fix AST export treating 0x7f as a valid name character Nov 12, 2026
@jorgsowa

Copy link
Copy Markdown
Contributor Author

Retargeted to PHP-8.6. The invalid-name quoting is already there via #22294, and 8.6 braces every interpolated variable, so the ${'---'} and "{$a}->b" cases are already handled. That leaves only the 0x7f fix.

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.

2 participants