DEV Community

Discussion on: Pitch me on PHP

Collapse
arpple profile image
Arpple

example from built-in function of core php
array_map receive callback first, array second
array_reduce receive array first, callback second

there are quite a number of this kind of inconsistency around

Thread Thread
ltsochevdev profile image
Sk1ppeR

Well you just lack experience if this is your biggest pet peeve. I agree, it's not a perfect system, but if you only pass an array to array filter it will filter out falsey values without you having to specify a callback. There's benefit in that

Thread Thread
arpple profile image
Arpple

this is not the biggest but it's the context of what I replied to.
and if array_filter have benefit of using array first, why not all other functions do the same?

Thread Thread
ltsochevdev profile image
Sk1ppeR

Either way, if you are coding in anything other than Notepad, your IDE will most likely help you with the argument order so in that regard, it really is a moot point. Most frameworks have all of this abstracted already. They also abstract strings. I don't see it being much different than Java world. Nobody codes in plain Java nowadays. Everybody simply learns the spring framework and "the spring way of doing things" and that is it.