-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Closure instead of callable for various methods of Routing package. #13744
Conversation
976f330
to
5e0037a
Compare
5e0037a
to
027175d
Compare
Its funny because I'm pretty sure I demo'd this exact thing - invokable classes for connected routes - a few years back for a microframework... |
8bd42bc
to
5a07ea8
Compare
@josegonzalez Do you think we should retain compatibility for invokable classes to be used in route building? How does it help build a microframework app? |
I think its a nice way to evolve your app into a more complex one from simple closures. Here is a list of what slimphp supports, one of which is an invokable class. I personally enjoy working with invokable classes as they can be registered easily and don't require a convention around the framework, instead relying on generic php :) |
While not clear from my comment my aim wasn't to prevent use of invokable but simply avoid callables as it covers a very wide range of values and callable checks can be expensive. I can replace the |
But using I wish PHP have a specific type for invokable classes 🙂. |
Perhaps we should stick with callable given the awkward alternative typehints. |
Yup, there might be some clean up I can salvage out of this so I will keep this open for now and update the PR or close later. |
I don't think anyone would be using invokable classes for connecting routes. For various router/routerbuilder methods we allow passing callback for 2nd params/options argument which is an array so using Closures only for callback are better for type checks.