laminas / laminas-inputfilter

Normalize and validate input sets from the web, APIs, the CLI, and more, including files
https://docs.laminas.dev/laminas-inputfilter/
BSD 3-Clause "New" or "Revised" License
42 stars 29 forks source link

Improve inference for `InputFilterPluginManager::get()` #97

Closed gsteel closed 10 months ago

gsteel commented 10 months ago

Currently, InputFilterPluginManager::get(FQCN::class) yields the union of InputFilterInterface|InputInterface.

Ideally, this would be the given FQCN when it implements one of those interfaces.

Also, the @method get docblock is problematic as it trumps any user defined stubs and causes other problems that I can't remember!

Because the plugin manager here is guaranteed to return InputFilterInterface|InputInterface as opposed to T|mixed, this conflicts with AbstractPluginManager::get().

Furthermore, I think psalm might have issues with class-string<PsalmAliasOfUnion>.

This patch provides correct inference for consumers when they provide a FQCN or string alias at the expense of 2 or 3 extra baselined issues that I believe are due to using a union type for InstanceType on the class level template.