Hi Yasuo

2014-12-04 9:28 GMT+01:00 Yasuo Ohgaki <yohg...@ohgaki.net>:
> Any comments?
>
> Regards,
>
> --
> Yasuo Ohgaki
> yohg...@ohgaki.net

I think we should solve these on a case-by-case basis, I can think of
one reason why the warning exists, and that is because it modifies the
array pointer and the argument is sent by reference. But I think we
can safely remove the warning if the parameter was not sent by
reference, as then we would expect the user to use the return value of
array_pop() to assign the value from. I don't think we should remove
warnings if you pass a statically value to it, sure some APIs can
return a variable length/dynamic array but then I think they should be
referenced into a variable and then passed to the function as they are
most likely going to be used later, I can't really think of a case
where it would be useful to send a return value of some API call to
array_multisort() and then use the boolean true or false to check if
it was a successful call for example..

For functions like next() that only supports taking the argument by
reference, this should remain (since the return value is the internal
array pointer position).

I went over the manual and the following should remain that warning:
array_multisort()
array_push()
array_shift()
array_unshift()
array_walk()
array_walk_recursive()
asort()
arsort()
each()
ksort()
krsort()
natsort()
natcasesort()
reset() -- Debatable though (does not many any sense, but if current()
and family is, and this is not, it will make it inconsistent)
rsort()
shuffle()
sort()
usort()
uasort()
uksort()


And the following can have the warning removed if the argument is not
passed by reference:
array_pop()
array_splice()
current() -- Debatable though
end() -- Debatable though (use array deferencing?)
extract()
key() -- Same as current()
next() -- Same as current()
prev() -- Same as current()


(Note, there is probably some I have missed, as I only looked for the
&$array in the prototype of the functions listed above)


Thoughts?


-- 
regards,

Kalle Sommer Nielsen
ka...@php.net

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

Reply via email to