Re: Re: Return Type Declarations

From: Date: Thu, 24 Apr 2014 18:23:54 +0000
Subject: Re: Re: Return Type Declarations
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-73784@lists.php.net to get a copy of this message
On Thu, Apr 24, 2014 at 12:18 PM, Adam Harvey <aharvey@php.net> wrote: > On 24 April 2014 11:15, Levi Morrison <morrison.levi@gmail.com> wrote: > >> Levi, what's the syntax like for closures with use blocks? I can see > >> that looking a bit weird either way, since it's presumably either: > >> > >> function ($foo): Bar use ($quux) {} > >> > >> or: > >> > >> function ($foo) use ($quux): Bar {} > >> > >> Neither are exactly ideal, but that's the hand we've dealt ourselves, I > >> guess. > > > > > > I believe it is the latter: function ($foo) use ($quux): Bar {} > > > > I'll check with Joe Watkins. Do you have a case for one being superior to > > the other? > > Not really — I think I prefer that one slightly, but they both require > a moment to parse. On the bright side, I don't see a lot of people > using return type declarations with closures. If we ever support type hints like `function array_sort(array &$array, callable($a, $b): int $callback)` then I can see us using type declarations with closures. Maybe. So in summary: after the use statement is visually a bit better. Perhaps someone will think of one reason to do the former but I'll just plan on documenting it as the latter option.

« previous php.internals (#73784) next »