Repository navigation
Add property_is_initialized - #41
Merged
Merged
Conversation
Tells an absent or uninitialised property apart from one that holds null, resolving the property in the same order as optional_property. A parity test keeps both in line.
This was referenced Oct 15, 2026
veewee
added a commit
to veewee/encoding
that referenced
this pull request
Oct 16, 2026
veewee/reflecta#41 adds Reflect\property_is_initialized(). Until 1.2.0 is tagged the branch comes in through a VCS repository aliased as 1.2.0. This commit gets replaced by a ^1.2 constraint after the release, so the branch cannot be merged before that.
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.
php-soap/encoding wants to stop writing
xsi:nilfor optional elements whose property was never set (php-soap/encoding#71). Afteroptional_property()reads null, the encoder has to tell a property that holds null apart from one that is missing or uninitialised. The answer follows the same PHP lookup rules the lens already handles, so I put it here instead of in the encoder.Reflect\property_is_initialized(object $object, string $name): boolresolves the property in the same order asoptional_property(): the class itself, then a dynamic property, then private properties on parent classes. It keeps no cache, returns noReflectionPropertyand never calls__get. When PHP throws while checking, for example in a lazy object whose initializer fails, it reports the property as present, so a caller keeps writing the value it read.I gave the function its own body instead of pulling a shared resolver out of
optional_property(), so the lens read path stays as it is. A parity test runs both over the same fixtures to catch drift.On PHP 8.4,
ReflectionProperty::isInitialized()initialises a lazy ghost or proxy, so calling this on a lazy object that nobody touched yet has that side effect.Cost per call next to
optional_property()(ns, PHP 8.4, xdebug off, median of 3 phpbench rounds):