3 ms·
It is true and no I don’t think there’s much talk of changing it. There’s also a problem with inconsistent method arguments. Just look at array_map[1] and array
by duncan-donuts 7y ago
It is true and no I don’t think there’s much talk of changing it. There’s also a problem with inconsistent method arguments. Just look at array_map[1] and array_reduce[2]. This is just the one example that bit me the most, but there are other inconsistencies like this all over the language that require you to constantly look things up.
[1] https://www.php.net/manual/en/function.array-map https://www.php.net/manual/en/function.array-map
[2] https://www.php.net/manual/en/function.array-reduce https://www.php.net/manual/en/function.array-reduce
- nkozyra 7y agoI remember reading a cogent explanation for this inconsistency but can't seem to locate it. JavaScript suffers from inconsistent mutation/return of array values in array functions, too. PHPs design problems are mostly being swept away; it's the legacy that keeps its reputation down.
- aspratley 7y agoRasmus Lerdorf has talked about it in other videos but this is one https://youtu.be/iGOAQli7tGc?t=1485 https://youtu.be/iGOAQli7tGc?t=1485 Basically, groups of functions are consistent: string,array etc. Their parameter order was usually based on whatever the underlying C API was.
- cdirkx 7y agoI just encountered this last week. I had to explain to my fellow non-IT students why I was making loud gasps of confusion.
- Moru 7y agoI use an editor that has the php help built in to not get confusing errors. You type the beginning of the command and it directly tells you what part is the needle and what is the haystack.
- dana321 7y agoArray map takes one or more arrays with a callback, so the arrays have to be on the end. Array reduce has one array as a parameter, as does most of the other functions and they all have the array as the first parameter. Its only one function, and its an inconsistency for a reason. Lets not blow it all out of proportion.