How many times you wrote code like this to achieve a simple purpose?
Mapping values of an array:
foreach ($items as $key => $item) {
}
Filtering:
foreach ($items as $key => $item) {
if (condition($item)) {
}
}
Or reducing an array to some value:
$acc = 0;
foreach ($numbers as $number) {
$acc += $number;
}
The above code samples involve the imperative programming style, which is familiar to everybody. It has a certain flaw: we have to parse the code in our head and go through negligible but required details to understand it.
To solve this issue, PHP s