yoshi129's avatar

Michał

yoshi129

Member since

215

Total Reputation

4

Total Arguments

5

Total Votes for Arguments

Arguments and votes

16

Nice addition, but I would change syntax:

class User 
{
    public string $name {
        set($value) {
            if (strlen($value) === 0) {
                throw new ValueError("Name must be non-empty");
            }
            return $value;
        }
    }
 
    public function __construct(string $name) {
        $this->name = $name;
    }
}
Share:
Read the RFC: Property Hooks yoshi129 avatar
yoshi129
voted yes
1

I think the proposition is not "must have" option but it's ok

Share:
Read the RFC: Short Closures 2.0 yoshi129 avatar
yoshi129
voted yes
1

Interface should be contract which a class must fulfill. They should not include any implementation. If you want share implementation you can use traits.

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

I like the proposition, but I would use some special "variable" ($$) for piped value (see v1 proposition: https://wiki.php.net/rfc/pipe-operator) so you don't have to use closures inside pipe to place value

$name = 'my_user_name'
	|> str_replace('_', ' ', $$)
	|> strtolower($$)
	|> ucwords($$)
	|> trim($$);

I don't like mapping function names as strings too

Share:
Read the RFC: The Pipe Operator yoshi129 avatar
yoshi129
voted yes
64

For me, the most important argument is that the pipeline pattern is a tried and tested pattern, that this RFC builds upon. A couple of examples:

This RFC adds syntax to make using these kinds of pattern much more convenient.

On top of that, there's the argument that multiple modern languages support a pipe operator:

Finally, I've had numerous occasions where a pipe operator would simplify my own code — I have more than a handful real life cases where this would be useful.

Share:
Read the RFC: The Pipe Operator Contributor brent avatar
brent
voted yes
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!