Repository navigation
Add TypeCollection::findByNameAndXmlNamespace - #30
Conversation
Returns an Option instead of throwing when the type is missing. fetchByNameAndXmlNamespace is now built on top of it and keeps its exception.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
The lookup runs on hot encode and decode paths, and an Option allocates on every call. Nullable keeps it as cheap as the keyed lookup itself.
php-soap/engine#30 adds TypeCollection::findByNameAndXmlNamespace(). Until it is released, the branch is aliased as 2.21.0 so php-soap/wsdl-reader's ^2.20 constraint still resolves.
Exceptions as lookup control flow
php-soap/encoding needs a type lookup that does not throw. Today it wraps
fetchByNameAndXmlNamespaceintry_catch(SoapArrayAccess.php:41-50), so every soap-enc array with a builtin item type throws and catches one exception just to learn the type is not in the metadata.Nullable find next to fetch
TypeCollection::findByNameAndXmlNamespace(string $name, string $namespace): ?Typeuses the same keyed lookup asfetchByNameAndXmlNamespaceand never throws.fetchByNameAndXmlNamespaceis now implemented on top of it, with the same exception and message, so the two cannot drift apart.The convention is:
fetch*throws when the type is missing,find*returns null. It is stated in the docblock.I did not add a
findFirstByNamecounterpart. Nothing needs it yet, and it can follow the same convention when something does.This is purely additive and intended for the next 2.x minor release.
Summary by CodeRabbit