[Capability] Make CompletionProvider's providerClass usable - #499
Open
chr-hertel wants to merge 1 commit into
Open
[Capability] Make CompletionProvider's providerClass usable#499chr-hertel wants to merge 1 commit into
chr-hertel wants to merge 1 commit into
Conversation
The constructor's exactly-one-source check never counted providerClass, so the form always threw, and discovery stored the (always null) provider for it.
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
September 5, 2026 00:50
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.
Two bugs made
#[CompletionProvider(providerClass: Foo::class)]impossible to use:array_filter([$provider, $values, $enum])—$providerClasswas never counted, so the form always threwOnly one of provider, values, or enum can be set.duringnewInstance(). Discovery catches that and drops the element, so the whole prompt/template silently disappeared.Discoverer::getCompletionProviders()then stored$attributeInstance->providerin theproviderClassbranch — alwaysnullthere. (ReflectedElementLoaderalready had this right.)Both are covered by a new integration test that drives a real client against a real server over stdio. The fixture's provider takes a scalar the auto-wiring container cannot supply, so it can only come from
Container::set()— completions arriving at all prove the attribute reached the registry and the container was asked to build it.Verified the test actually catches both bugs: with neither fix the prompt is missing entirely (
Prompt not found: "book_seat"), with only the constructor fixed the completions come back empty.Note that
provider:already accepts aclass-string<ProviderInterface>and resolves it the same way, soproviderClassis a redundant spelling — worth a follow-up on whether to deprecate one of them. This PR only stops the advertised parameter from throwing.Found by Copilot's review on #492.