--- title: 'You can use generic class-string annotations to hint that an instance of the passed class is returned' tweet_id: '1479467944581033986' thread_slug: weekly-thread-2021-01 author_username: freekmurze images: - 'https://pbs.twimg.com/media/FIN1v4NWUAARbol.jpg' created_at: 2022-01-07T15:00:19+00:00 slug: 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