Repository navigation
Skip pipe/array_map optimization for forbid-dynamic-calls functions - #25672
Open
prateekbhujel wants to merge 2 commits into
Open
prateekbhujel wants to merge 2 commits into
prateekbhujel wants to merge 2 commits into
Conversation
When zend_partial_apply() rewrites an FCC/PFA in array_map() or |> into a direct call, functions and static methods flagged with ZEND_ACC2_FORBID_DYN_CALLS bypass zend_forbid_dynamic_call() and run in the caller's scope (e.g. extract(), compact(), func_get_arg()). Resolve the callable name in zend_is_pipe_optimizable_callable() and skip the optimization if it targets a ZEND_ACC2_FORBID_DYN_CALLS function or static method (including namespace fallback and aliases). Resolving the name also fixes aliased assert() hitting an assertion failure in zend_ast_export_ex().
arnaud-lb
reviewed
Nov 24, 2026
| return !fbc || !(fbc->common.fn_flags2 & ZEND_ACC2_FORBID_DYN_CALLS); | ||
| } | ||
|
|
||
| static bool zend_is_pipe_optimizable_method_name( |
Member
There was a problem hiding this comment.
We can ignore method calls for now: We do not have any methods like that except in ext/zend_test and we can not implement this check reliably as we don't generally know the CE.
Contributor
Author
There was a problem hiding this comment.
Fair enough, dropped the method call check and the zend_test test in 0a9510d, just checking function names now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #25546 for the
extract()/compact()/func_get_arg()case in GH-25379.When
zend_partial_apply()optimizes an FCC/PFA inarray_map()or|>, rewriting it into a direct call skips the dynamic call check so functions flagged withZEND_ACC2_FORBID_DYN_CALLSend up running directly in the caller's scope instead of throwingError: Cannot call ...() dynamically.This checks
ZEND_ACC2_FORBID_DYN_CALLSinzend_is_pipe_optimizable_callable_name()(covering resolved function names, aliases, and namespace fallback to global functions). Resolving the function name there also avoids hitting theassert()assertion failure whenassertis imported under an alias likeuse function assert as a;./cc @arnaud-lb