3 ms·
For example you can't just write [1, 2, 3]->map(...) in PHP. Right now the best is to use something like Laravel's collect, e.g. collect([1, 2, 3])->map(...).
by thibran 8y ago
For example you can't just write [1, 2, 3]->map(...) in PHP.
Right now the best is to use something like Laravel's collect, e.g. collect([1, 2, 3])->map(...). Oftentimes all you want is to add one method to an object. Right now you would have to sub-class it or write an ugly wrapper function.
Infix-Functions are one way to "extend" functionality without messing with inheritance – with other words, you can easier express what you mean with less code in an consistent way. In Android dev, Kotlin and Infix-Functions are quite popular. Too often in PHP you have to write some_function($object). The other thing is that PHP has a lot of strange function names and Infix-Functions could help to give the language designers a second chance to come up with better names, even if the Infix-Functions just call the existing code.
- Something1234 8y agoI would be fan of adding some kind of in-place map as a method on an array to php, but other that that I don't see much benefit to it.