You can use generic class-string annotations to hint that an instance of the passed class is returned

You can use generic class-string annotations to hint that an instance of the passed class is returned

This is how you can hint that a function returns an instance of the class of which you passed the class name.

Cool stuff!

Hat tip to @enunomaduro

https://github.com/spatie/laravel-route-discovery/blob/7fa88922aa693b03b4763eda870867075ab44999/src/PendingRoutes/PendingRouteAction.php#L100-L107

We're writing a book, you can get it for free here.