laminas / laminas-router

Flexible routing system for HTTP and console applications
https://docs.laminas.dev/laminas-router/
BSD 3-Clause "New" or "Revised" License
34 stars 15 forks source link

`RoutePluginManager` has incorrect generic statements #56

Open boesing opened 8 months ago

boesing commented 8 months ago

Bug Report

Q A
Version(s) 3.6.0 until latest

Summary

The RoutePluginManager is a plugin manager implementations. Plugin manager implementations have to provide their generic type instead of passing it to someone else.

Current behavior

https://github.com/laminas/laminas-router/blob/fceae295d4333bc395c496ee614b7a14e24828be/src/RoutePluginManager.php#L30-L31

How to reproduce

Just consume the route plugin manager via service manager and then use either get or build method. Psalm is only able to infer mixed|object instead of RouteInterface (which is the instance the plugin manager provides).

https://github.com/laminas/laminas-router/blob/fceae295d4333bc395c496ee614b7a14e24828be/src/RoutePluginManager.php#L41

Expected behavior

- * @template InstanceType of RouteInterface
- * @extends AbstractPluginManager<InstanceType>
+ * @extends AbstractPluginManager<PluginInterface> 
 * @psalm-import-type ServiceManagerConfiguration from ServiceManager
 */
class RoutePluginManager extends AbstractPluginManager
Xerkus commented 8 months ago

This implies service manager annotations are wrong somehow. Actually it looks like what we seen with template constraints in inputfilter today.

boesing commented 8 months ago

Service manager does not provide generics on class Level. So these cant be wrong. only plugin managers have class-level generics as these are limited to specific class implementations via instanceOf property.

This has been further improved in v4 of servicemanager via "SingleInstancePluginManager" abstraction.

might just be Inputfilter having invalid generics as well.