Skip to content

fix: specify closure handler signature - #475

Draft
simonyang08 wants to merge 1 commit into
modelcontextprotocol:mainfrom
simonyang08:codex/fix-handler-closure-type
Draft

fix: specify closure handler signature#475
simonyang08 wants to merge 1 commit into
modelcontextprotocol:mainfrom
simonyang08:codex/fix-handler-closure-type

Conversation

@simonyang08

@simonyang08 simonyang08 commented Aug 22, 2026

Copy link
Copy Markdown

Summary

  • give the registry handler Closure alias an explicit variadic signature
  • allow strict PHPStan users to decorate RegistryInterface without a missing callable signature error

Root cause

The Handler PHPStan alias used a bare \Closure, so consumers inheriting the alias received missingType.callable under strict analysis.

Current validation status

  • consumer-only minimal PHPStan reproducer: fails before and passes with the proposed alias
  • ReferenceHandlerTest: 4 tests, 9 assertions pass
  • git diff --check: passes

Upstream CI exposed a variance conflict that the isolated reproducer missed: the proposed Closure(mixed...): mixed type rejects the repository's valid handlers with narrower required parameter lists. The full PHPStan job reports 29 argument.type errors introduced by this alias. The PR is therefore intentionally Draft while the correct way to represent an arbitrary Closure signature is discussed; the current commit should not be merged as-is.

Fixes #468

@simonyang08
simonyang08 marked this pull request as ready for review August 22, 2026 06:07
@simonyang08
simonyang08 marked this pull request as draft August 22, 2026 06:14
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.

[Server] Handler type uses bare Closure, hard to decorate RegistryInterface under strict PHPStan

2 participants