Repository navigation
Language: self::/parent:: static FCC preserves late static binding (#27835) - #27844
Merged
Merged
Conversation
…27835) Keep fromCallableScope when baking self/parent to FQCN, store creation called_scope on the Closure, and use it on invoke so B::viaSelf() with self::foo(...) yields B (Zend), not declaring class A. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Summary
self::method(...)/parent::method(...)first-class callables created in a static method so invoke preserves creation-time late static binding (Zendzend_closures.c).self/parentto a FQCN for AOT/JIT and dropped the keyword; VM then setcalledClassfrom that FQCN, soB::viaSelf()withself::foo(...)printedA:sinstead ofB:s. NamedA::foo(...)correctly stays frozen toA.fromCallableScope, storeboundCalledScopeClassfrom the creating frame, and useclosureCalledScopeClass()on wrappedFunc invoke (Language: self::method(...) FCC from child loses late static binding — static::class is parent (Zend/zend_closures.c) #27835).Closes #27835
php-src reference
Zend/zend_closures.c— fake closure called_scopeZend/zend_compile.c—ZEND_AST_CALLABLE_CONVERT/self::FCCTest plan
Observed:
Aself=A:s/Bself=B:s/Anamed=A:s/Bnamed=A:s(exit 0).parent::static FCC LSB (C::viaParent()→C:s) also fixed by the same pathvendor/bin/phpunit --filter FirstClassCallableTest::testVmSelfStatic→ OKvendor/bin/phpunit --filter first_class_callable_self_static_lsb test/compliance/ClosureVMTest.php→ OKparent_method,parent_method_args,parent_static) → OKbootstrap-inventory --checkOK 7020/7020; release-readiness completed (exit 0)Made with Cursor