Repository navigation
Conversation
…ed typed property
Contributor
Author
|
Tests will be green after #24566 lands, i put this PR to draft, but it's ready for the review. I'll rebase later on. |
adapik
marked this pull request as draft
October 30, 2026 17:29
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.
Modern PHP code mostly initializes properties through constructor property promotion, often with readonly (DTOs, value objects, services). Every such property is a typed property without a default, so its first write always goes through
zend_std_write_property().This PR adds a fast path in
ZEND_ASSIGN_OBJfor the case where the cache slot is hit, the property isIS_UNDEFwithIS_PROP_UNINITset (never unset()), and neither the property nor the object is lazy. A newzend_assign_to_uninit_typed_prop()verifies the type and stores the value.Results (release build, callgrind over 200k constructor calls with promoted readonly properties):
Two new tests cover coercion, union and class types, readonly, protected(set), hooks and lazy objects.
This PR is related to #24566 and relies on it: that fix makes sure a failed write doesn't leave the cache slot primed. Without it, this fast path would also let a first write bypass those checks. It would be best if this lands after #24566.
Follow-up to #22709.