After recently having to work with modern PHP, I have to say a lot of the criticism of the language is unfounded. It's changed a lot since I first used it. But the stdlib is still hard to manage. Different naming conventions, different order on the parameters for functions that do almost the same thing, and every function is global. Couldn't they keep all that for backwards compatibility, but create more sane wrapper…
Despite peoples grumblings about parameter order the only real reasonless difference is string functions are haystack / needle, whereas array functions are needle / haystack. Once you know that its not that difficult. Some other minor inconsistencies like array_map vs. array_filter are simply due to the fact that optional parameters have to be at the end of function calls. On array_filter the callback is optional, wh…
$asBools = partial_apply('array_map', 'boolval');
$asBools(['hello', '', 'world']) === [true, false, true]
$asBools([-2, -1, 0, 1, 2]) === [true, true, false, true, true]
array_filter and array_reduce get this wrong, requiring awkward argument-shuffling: $inverseFilter = partial_apply(flip('filter'), 'boolNot');
$inverseFilter([-2, -1, 0, 1, 2]) === [2 => 0]
array_keys($inverseFilter(['foo' => true, 'bar' => false])) === ['bar']
$allTrue = partial_apply(flip(partial_apply(flip('array_reduce'), 'boolAnd')), true);
$allTrue(['hello', 'world']) === true
$allTrue([true, true, 0, true]) === false
Note that a) if specialisation was easy, there would be no need for default arguments and b) having default arguments at the end is exactly the wrong way around for making specialisation not suck.We could sweep this under the rug by saying it's awkward because it's not idiomatic PHP; but one reason why it's not idiomatic is that it's awkward!
Just look at Javascript, where functions are slightly less awkward; there are lots of functional APIs in wide use, eg. Underscore.