On 12 February 2020 23:12:34 GMT+00:00, Manuel Canga <manuelca...@gmail.com> 
wrote:
>El mié., 12 feb. 2020 23:01, Rowan Tommins <rowan.coll...@gmail.com>
>escribió:
>In your example, you has the same options:
>
>>
>1. Change import
>2. Add namespace:
>
>['Acme\Global\I18N',\translate::function]


There is no collision between 'Foo::translate()' and 'translate()', so there is 
no reason to change the import. That's true of executing the functions, so it 
should remain be true of resolving them to strings.



>Explain:
>
>When you do: [ class, method ] or [ $object, method ]. Method has not
>namespace, you write it without namespace( like global functions )


I think this is where we are thinking differently. A method name is not "like a 
global function", it's just a name; it doesn't belong in the same category. 

You might have any number of classes that use the same method name, but with 
completely different parameters and purpose, so "a method named foo" isn't a 
useful concept outside some specific class or interface.

On the other hand, you can only have one function with a particular 
fully-qualified name, and the proposed feature is a way of referencing that.



>Other example:
>
>$class = \MyClass::class;
>$method = \method::function;
>
>and...
>
>$class = '\MyClass';
>$method = 'method';
>
>$obj = new $class();
>$obj->$method();
>
>Both are the same, but first is more semantic.


This isn't semantic at all - it works only because \method::function happens to 
return the string you want, but so does \method::class; neither is actually 
labelling it as what it is, which is a method within class \MyClass.

Importantly, it might not work at all, if ::function gives an error if the 
function doesn't exist. 

Regards,

-- 
Rowan Tommins
[IMSoP]

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

Reply via email to