Skip to content

Add TypeCollection::findByNameAndXmlNamespace - #30

Merged
veewee merged 2 commits into
php-soap:mainfrom
veewee:feature/find-type-by-name-and-namespace
Oct 15, 2026
Merged

veewee merged 2 commits into
php-soap:mainfrom
veewee:feature/find-type-by-name-and-namespace

Conversation

@veewee

@veewee veewee commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Exceptions as lookup control flow

php-soap/encoding needs a type lookup that does not throw. Today it wraps fetchByNameAndXmlNamespace in try_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): ?Type uses the same keyed lookup as fetchByNameAndXmlNamespace and never throws. fetchByNameAndXmlNamespace is 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 findFirstByName counterpart. 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

  • New Features
    • Type collections now support looking up a type by its name and XML namespace, returning no result when there is no match. This allows callers to check for a matching type without receiving an error.
    • The required lookup remains available: it returns the matching type when found and reports an error when no match exists. Both lookup options use the same name-and-namespace criteria.

Returns an Option instead of throwing when the type is missing.
fetchByNameAndXmlNamespace is now built on top of it and keeps its
exception.
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 22e04472-1bb5-4465-a7c2-e24e432f9bea
📥 Commits

Reviewing files that changed from the base of the PR and between d86c497 and 1cda5d9.

📒 Files selected for processing: 2
  • src/Metadata/Collection/TypeCollection.php
  • tests/Unit/Metadata/Collection/TypeCollectionTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

TypeCollection adds an Option-based lookup by type name and XML namespace. The existing throwing lookup delegates to the new method. Tests cover matching and nonmatching names and namespaces.

Changes: Qualified type lookup

Layer / File(s) Summary
Qualified lookup and tests
src/Metadata/Collection/TypeCollection.php, tests/Unit/Metadata/Collection/TypeCollectionTest.php
findByNameAndXmlNamespace returns an Option for the qualified lookup. fetchByNameAndXmlNamespace delegates to it and throws MetadataException::typeNotFound($name) when no type is found. Tests cover a match, an unknown name, and a nonmatching namespace.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Merge Risk: ⚪ Minimal · up to 1cda5

The new nullable lookup preserves the existing qualified lookup behavior, and the throwing API retains its missing-type error.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: adding TypeCollection::findByNameAndXmlNamespace.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@veewee
veewee merged commit b43083e into php-soap:main Oct 15, 2026
7 checks passed
veewee added a commit to veewee/encoding that referenced this pull request Oct 15, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant