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]

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to