Cache inner iso in XsiTypeEncoder#52
Merged
veewee merged 4 commits intophp-soap:mainfrom Mar 26, 2026
Merged
Conversation
Captures $this->encoder->iso($context) once in iso() and passes the result to the private to() and from() methods. This avoids rebuilding the inner iso on every encode/decode invocation. In from(), when xsi:type detection resolves to the same encoder, the cached iso is reused instead of calling iso() again.
Encoders accept string|Element in from() by design, but the Iso generic is typed as Iso<mixed, string>.
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
$this->encoder->iso($context)once iniso()instead of calling it on every encode/decode invocationto()andfrom()methods for readability, just passes the cached iso as a parameterfrom(), reuses the cached iso when xsi:type detection resolves to the same encoderImpact
Negligible in isolation (~1%), but establishes the pattern that
iso()should capture its dependencies eagerly. This becomes more meaningful when combined with downstream caches (ObjectAccess, XsiTypeDetector).Test plan