by allendoerfer · 4y ago · 0 comments
a) Make everything an object, where methods can be called on:
$arr = [];
$arr->key_exists('key');
b) Create a new class-based standard library, where you call those functions statically and needle/haystack are always in the same place: Arr::key_exists($arr, 'key');
Either way, you can deprecated all the array_..., str_..., etc. functions and end the guessing game. Other than that PHP is turning out great.It’s simple to use, but extremely powerful. I pretty much always use Collections over native array functions these days.
Even before auto-completion I guess I would just read the docs.
To each his own I guess.
Reading the docs of course helps, but it is still inconvenience and waste of time to check inconsistent parameter order and function naming from docs. I don't understand why people are so keen on defending these things.
Except when they have different order :)
array_filter(array $array, ?callable $callback = null, int $mode = 0): array
array_map(?callable $callback, array $array, array ...$arrays): arrayAnd IDEs completely solve the problem of knowing parameter orders by hinting them as you type the functions.
This really isn't that big of a deal.