Cache type iso in ElementEncoder, refactor value builder/reader#53
Merged
veewee merged 1 commit intophp-soap:mainfrom Mar 26, 2026
Merged
Conversation
…ementValueReader ElementEncoder now captures the type iso once via $typeEncoder->iso($context) and passes it to ElementValueBuilder::fromIso() and ElementValueReader::forIso(), avoiding redundant iso rebuilds on every encode/decode invocation. ElementValueBuilder: - Constructor is now private; use fromEncoder() or fromIso() static factories - Stores a list of builder closures composed at construction time - Value encoding happens lazily via a valueProvider closure during __invoke - Removed deprecated resolveXsiTypeForValue/shouldIncludeXsiTargetNamespace ElementValueReader: - Added forEncoder(context, encoder, element) and forIso(iso, element) static methods for callsites with or without a cached iso - __invoke delegates to forEncoder for backwards compatibility SoapObjectEncoder, ApacheMapEncoder: switched to ElementValueReader::forEncoder().
d9d40f8 to
fe5b6a8
Compare
3 tasks
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
Captures the type iso once in
ElementEncoder::iso()and passes it through to avoid redundantiso()rebuilds on every encode/decode call.ElementValueBuilder
fromEncoder()andfromIso()fromIso()accepts a pre-built iso (used by ElementEncoder which caches it)fromEncoder()builds the iso on the fly (for callsites without a cached iso)__invoke, not eagerly in the constructorresolveXsiTypeForValue()/shouldIncludeXsiTargetNamespace()ElementValueReader
forEncoder(context, encoder, element)andforIso(iso, element)static methods__invoke()delegates toforEncoder()for backwards compatibilityforIso()is used by ElementEncoder;forEncoder()by SoapObjectEncoder and ApacheMapEncoderImpact
~1% improvement (negligible in isolation). The value is in the cleaner API and in establishing the pattern that the iso should be captured once at
iso()construction time.Test plan