letssurf's avatar

James Dempster

letssurf

Member since

50

Total Reputation

3

Total Arguments

4

Total Votes for Arguments

Arguments and votes

1

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;
}
Share:
Read the RFC: The Pipe Operator letssurf avatar
letssurf
voted no
1

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.

Share:
Read the RFC: Interface Default Methods letssurf avatar
letssurf
voted no
1

seems obvious

Share:
Read the RFC: Short Closures 2.0 letssurf avatar
letssurf
voted yes
121

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...

Share:
Read the RFC: Short Closures 2.0 davi avatar
davi
voted yes
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!