Skip to content

[Discovery] Replace Discoverer by-ref plumbing with DiscoveryState accumulator - #48

Open
chr-hertel wants to merge 1 commit into
mainfrom
fix/issue-19-discoverer-accumulator
Open

[Discovery] Replace Discoverer by-ref plumbing with DiscoveryState accumulator#48
chr-hertel wants to merge 1 commit into
mainfrom
fix/issue-19-discoverer-accumulator

Conversation

@chr-hertel

Copy link
Copy Markdown
Owner

Closes #19.

Discoverer::processMethod() was a 90-line switch over four attribute classes mutating five by-reference out-parameters. Now:

  • processMethod() returns a single element reference (or null), dispatching to four small per-attribute builders.
  • processFile() and discover() thread an immutable DiscoveryState through instead of five &$refs; the new DiscoveryState::add() keys each element by its identity (tool/prompt name, resource URI, template URI template).
  • The redundant $discoveredCount bookkeeping is gone — the final log derives counts from the state.

Scope note: the issue's other two sub-findings — Builder::add() match and the ReferenceHandler::handle() cascade — are left out here; they belong with #10/#12.

Tests, php-cs-fixer, and phpstan all green; DiscoveryState::add() got dedicated tests.

Confidence: 9/10 — pure structural refactor, discovery output and keying unchanged, full unit suite passes; only exotic behavioral delta is that subclasses of the Mcp* attributes (matched via IS_INSTANCEOF but previously dropped by the exact-classname switch) are now processed.

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.

[B5] Type switches instead of polymorphism

1 participant