array_map asks for the $array input as the last parameter(s). array_filter and array_reduce take $array input as the first parameter. As a contrasting example, when you call map, filter or reduce on an array in JavaScript, the callback function signatures look like
(current, index, array) => {…}
Array.prototype.reduce takes the carryover value as the first parameter, but it is still impossible to mix up the parameters' order in the JavaScript methods.
I know that PHP isn't functionally-oriented, but I'm wondering what the design decisions were leading to the signatures for array_map etc.
Does array_map take an array as the last parameter simply because you can feed as many arrays as you want (variadic)? Does the ability to feed an arbitrary number of arrays through the callback function of array_map outweigh having more uniform function signatures?
EDIT/ Comment:
from Wikipedia, this puts in perspective just how long PHP has been evolving:
'Early PHP was not intended to be a new programming language, and grew organically, with Lerdorf noting in retrospect: "I don’t know how to stop it, there was never any intent to write a programming language […] I have absolutely no idea how to write a programming language, I just kept adding the next logical step on the way." A development team began to form and, after months of work and beta testing, officially released PHP/FI 2 in November 1997. The fact that PHP was not originally designed but instead was developed organically has led to inconsistent naming of functions and inconsistent ordering of their parameters. In some cases, the function names were chosen to match the lower-level libraries which PHP was "wrapping", while in some very early versions of PHP the length of the function names was used internally as a hash function, so names were chosen to improve the distribution of hash values.'
array_map,array_reduceandarray_filterwere added into PHP in 4.0.6 (released in 2001). It looks likeArray.prototype.reducewas introduced in ECMAScript 5.1, which was published ten years later (in 2011).