On 7 March 2015 22:47:48 GMT, Yasuo Ohgaki <yohg...@ohgaki.net> wrote:
>Hi Rowan,
>
>On Sun, Mar 8, 2015 at 3:35 AM, Rowan Collins <rowan.coll...@gmail.com>
>wrote:
>
>> On 06/03/2015 23:03, Yasuo Ohgaki wrote:
>>
>>> We have a lot of array_u*() functions such as
>>>
>>> http://php.net/manual/en/function.array-uintersect-uassoc.php
>>> array array_uintersect_uassoc ( array $array1 , array $array2 [,
>array
>>> $...
>>> ], callable $value_compare_func , callable $key_compare_func )
>>> this can be consolidated to
>>> http://php.net/manual/en/function.array-intersect-assoc.php
>>> array array_intersect_assoc ( array $array1 , array $array2 [, array
>$...
>>> ]
>>> )
>>>
>>> All of these has callback the end of parameters. These may be
>>> consolidated.
>>> I'll add this to the RFC if this is preferred.
>>>
>>
>> Those functions both take any number of arguments, so given a
>function
>> call with 4 arguments, you can't know if that's 4 arrays, or 2 arrays
>and 2
>> callbacks. Don't forget that array($class_name, $method_name) is a
>valid
>> callback, so you can't judge it by the type of the arguments either.
>
>
>Thank you for heads up. If I detect array($class_name, $method_name) as
>callback, there could
>be unintended callback calls.
>
>Since we have been deprecated similar
>call_user_method()/call_user_method_array(), we may
>deprecate array callbacks for u* functions, then consolidate in the
>future,
>perhaps PHP8.
>I don't mind add this to the RFC.

What? That's not the same thing at all. I'm pretty sure those functions are 
deprecated *because* we have array callback forms, so you can use 
call_user_func to call a method.

PHP has a well-defined definition of "callable", as used by is_callable() and 
function parameter typehints, and literally everywhere that wants a callback. 
Since there's no such thing as a function or method pointer, that definition 
includes a string identifying a plain function, and two array forms, [string, 
string] and [object, string], representing static and instance methods, 
respectively. You can't not accept those forms as a callback parameter in one 
particular function just to make things tidier.

Regards,
-- 
Rowan Collins
[IMSoP]


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

Reply via email to