Member since
You could do this simply enough in userland code
pipe(
'Hello world',
htmlentities(...),
'str_split',
fn($x) => array_map('strtoupper', $x),
fn($x) => array_filter($x, fn($v) => $v != 'O'),
);
function pipe(...$pipes) {
$result = array_shift($pipes);
foreach ($pipes as $pipe) {
$result = $pipe($result);
}
return $result;
}
This is what an abstract class is for. Using Brents blog example, you'd create a default instance which was an abstract, this abstract would implement the default methods and the interface.
seems obvious
At least once a week, I throw away an array_map because it ended up looking too bloated and go with a classic foreach instead. Short Closures 2.0 without the use(...) block would've solved this problem, just 2 votes...