You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then using reflection the return type of the \Closure could be used as the abstract. This would be in line with some of the changes over the years to things like the EventFake's assertDispatched method where a \Closure can be provided with a type hint for the first parameter to the closure, configuring which Event class to expect to be dispatched, reducing the arguments to the method.
This functionality could be additive to Laravel as far as I can tell as there's no type hinting on the $abstract arg to stop the use of a \Closure. Instead when a \Closure is used.
Additonal Benefit
In the future, Closures with a return type hint can be used with Container::getBindings() to work out what Class will be returned and allow for a debug container command to be created to display more info about what the container has bound and where in the code base it was added to the container via reflection as well.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
It would be pretty easy to make the following possible:
Then using reflection the return type of the \Closure could be used as the abstract. This would be in line with some of the changes over the years to things like the EventFake's assertDispatched method where a \Closure can be provided with a type hint for the first parameter to the closure, configuring which Event class to expect to be dispatched, reducing the arguments to the method.
This functionality could be additive to Laravel as far as I can tell as there's no type hinting on the
$abstract
arg to stop the use of a \Closure. Instead when a \Closure is used.Additonal Benefit
In the future, Closures with a return type hint can be used with
Container::getBindings()
to work out what Class will be returned and allow for a debug container command to be created to display more info about what the container has bound and where in the code base it was added to the container via reflection as well.Work
Happy to add this if it would be accepted.
Beta Was this translation helpful? Give feedback.
All reactions