Skip to content

[PFA 3/n] Support PFA in const exprs#22785

Draft
arnaud-lb wants to merge 9 commits into
php:masterfrom
arnaud-lb:partials-const-expr-simple
Draft

[PFA 3/n] Support PFA in const exprs#22785
arnaud-lb wants to merge 9 commits into
php:masterfrom
arnaud-lb:partials-const-expr-simple

Conversation

@arnaud-lb

Copy link
Copy Markdown
Member

See individual commits. First two are GH-22783 and GH-22784, which will be merged separately.

Preloading will try to evaluate class constants during compilation, but
evaluated FCCs are objects, which can not be persisted. Apply the same fix as
for enums: Fail evaluation when compiling.

Preloading will also reset CG(map_ptr_last) after compilation, which results in
collisions if map ptrs were allocated during compilation. Move the
ZEND_MAP_PTR_NEW() to the persist phase, as a shared map ptr is not necessary
before that.
@arnaud-lb arnaud-lb changed the title [PFA 3/n] Support PFA in const exprs [wip][PFA 3/n] Support PFA in const exprs Jul 17, 2026
@arnaud-lb
arnaud-lb force-pushed the partials-const-expr-simple branch from 0ff8119 to f5a4f79 Compare July 17, 2026 15:22
@arnaud-lb arnaud-lb changed the title [wip][PFA 3/n] Support PFA in const exprs [PFA 3/n] Support PFA in const exprs Jul 17, 2026

@TimWolla TimWolla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I reviewed the PR excluding the first two commits. The tests LGTM. For the implementation, I didn't see obvious issues (except formatting nits), but I'm not fully comfortable approving the C changes.

Comment thread Zend/tests/partial_application/constexpr_009.phpt Outdated
Comment thread Zend/zend_compile.c Outdated
Comment thread Zend/zend_ast.c Outdated
… of the declaring opline itself

This makes the API compatible with creating partials from AST:
We can pass &ast->lineno to zend_partial_create()
The declaring op_array is used for multiple purposes:
 * Generating a PFA name
 * Finding the filename
 * Finding whether op_array is cached, and therefore whether the PFA should be
   cached too

However it's not available when evaluating a PFA AST.

Remove the declaring_op_array argument, and pass the relevant information
directly:
 * Generate the PFA name at compile time, pass it as argument to zend_partial_create()
 * Pass the filename and a cacheable flag as argument to zend_partial_create()
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