As of PHP 8.3.9 PHP doesn't allow type hinting within the use statement. Consider the following Laravel route:
Route::get('/tags/{tag}', function (string $tag) use ($posts): View {
$tagPosts = $posts->filter(
function (Post $post) use ($tag): bool {
return in_array($tag, $post->tags);
}
);
return view('tags.show', [
'posts' => $tagPosts,
'tag' => $tag
]);
});
As you can see I can make the code more verbose in the closures by type hinting the parameters and the return type. use however doesn't allow type hinting.