Repository navigation
Conversation
iliaal
approved these changes
Oct 31, 2026
|
|
||
| ZEND_MAP_PTR_SET(fcc_ast->fptr, fptr); | ||
| /* The AST may be shared between scopes (e.g. via traits), so only cache scope-independent results. */ | ||
| if ((ast->child[0]->attr >> ZEND_CONST_EXPR_NEW_FETCH_TYPE_SHIFT) == ZEND_FETCH_CLASS_DEFAULT |
Member
There was a problem hiding this comment.
This also disables caching for self::/parent:: and non-public FCC in non-trait default args, where the AST isn't shared and the scope is fixed, so those re-resolve the method on every default-arg evaluation. Correct as a simple fix, but worth a sentence in the description: narrowing it to only shared (trait) ASTs isn't cheap to detect at this point.
| <?php | ||
|
|
||
| trait T { | ||
| public static function make($f = A::who(...)) { return $f(); } |
Member
There was a problem hiding this comment.
Could you add a case for the branch that still caches across scopes? A trait with a named public-method default (A::who(...)) used by two classes, both returning A. 005 covers named+private; the named+public cached path isn't exercised.
Contributor
Author
There was a problem hiding this comment.
Makes sense. test case added.
The resolved method was cached on the shared AST node, so self::/parent:: and visibility were only checked for the first class evaluating it.
jorgsowa
force-pushed
the
fix-fcc-const-expr-trait-cache
branch
from
November 1, 2026 20:43
cb0f70b to
c4fa1c9
Compare
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.
The resolved method was cached on the shared AST node, so self::/parent:: and visibility were only checked for the first class evaluating it.