ConFoo Montreal 2026: Call for Papers

Voting

: max(seven, six)?
(Example: nine)

The Note You're Voting On

petersenc at gmail dot com
1 year ago
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.

<< Back to user notes page

To Top