RouteCollection get method has wrong return type in PHPDoc #54541
-
Laravel Version11.x PHP Version8.4 Database Driver & VersionMysql DescriptionRouteCollection get method has wrong return type in PHPDoc The method
says it returns an array of if you take a look at the implementation of it seems that all if conditions will return an array of except for this one which can iterate to the deepest level of the array and return the
this can give warnings in static analytics and code sniffers and other tools so I guess that the return type should be Steps To Reproduce
somewhere in the code call if according to the PHPDoc you assume that the return value is an array of |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The doc block says:
And the parameter is called Why are you querying using dot notation? Maybe we could filter out valid methods ( From the method's documentation, and expectations, there are no unexpected outcomes. |
Beta Was this translation helpful? Give feedback.
-
Yes the doc description and the parameter names are clear. So i would say that doc description and parameter name does not match with what the actual implementation do. It actually do return array of routes if you search by method and will return one route as object if you search by mehod.uri |
Beta Was this translation helpful? Give feedback.
-
I see what you mean. But bear in mind, this class implements against an interface. Not just the PHP docs, but an actual interface/contract ( So I would say the implementation needs to be fixed to comply with the interface expectations, and not the interface to be loosened to allow for an implementation oversight. Also, there are other implementations (e.g. You can propose a PR to fix the implementation. I guess instead of using In the meanwhile, just don't use the dot notation. It is not meant to be used by like that. |
Beta Was this translation helpful? Give feedback.
-
Exactly, I agree with you. Thanks for the discussion. |
Beta Was this translation helpful? Give feedback.
-
PR mrged |
Beta Was this translation helpful? Give feedback.
PR mrged
#54672