On Tue, 22 Oct 2024, 02:30 Valentin Udaltsov, <udaltsov.valen...@gmail.com> wrote:
> > What if instead of this proposal we reimplement all of the array > functions in a different namespace and fix a lot of other problems and > inconsistencies? > > Array\map(iterable $iterable, callable $mapper): array > Array\sort(iterable $iterable, int $flags = SORT_REGULAR): array > ... > > -- > Valentin Getting off-topic here, but array_map()'s parameter order matters. Because it can receive one or more arrays, the callback should be the first parameter to afford, say, spreading the rows of a multidimensional array during transposition. The same "spreadability" logic should apply to array_*diff*(), array_*intersect*(), and array_multisort(). If we were going for consistency, always write callbacks as the first parameter for any function that has one. In other words, parameters which can be repeated more than once must be list as the last parameter. It is clear that this RFC is seeking success by making the smallest possible, very practical change. While it is healthy to explore deviations, I like the RFC on it's own because it makes PHP more adaptable to writing elegant code with fewer temporary variables. Mick >