Re: [RFC]

From: Date: Wed, 12 Feb 2020 21:36:31 +0000
Subject: Re: [RFC]
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-108519@lists.php.net to get a copy of this message
On 11/02/2020 15:13, Manuel Canga wrote:
One case which string can be useful but a callable would not be acceptable is: array_map([I18N::class, translate::function] );
I wouldn't expect that to work anyway, because the whole purpose of the keyword would be to resolve "translate" as a function name, not a method name, e.g. use Acme\Global\I18N; use function Acme\Global\translate; var_dump([I18N::class, translate::function]); # array(0 => 'Acme\Global\I18N', 1 => 'Acme\Global\translate') # not a valid callable var_dump([I18N::class, 'translate']); # array(0 => 'Acme\Global\I18N', 1 => 'translate'); # this was what was intended If you didn't want to quote the method, you'd need some other syntax that took both class and method name, like: [I18N, translate]::callable Or as proposed elsewhere in the thread: $(I18N::translate) Regards, -- Rowan Tommins (né Collins) [IMSoP]

« previous php.internals (#108519) next »