Hi everyone,
I think I've got this RFC into the expected state needed to announce it and
open discussion.
Trailing Boolean Operators
https://wiki.php.net/rfc/trailing_boolean_operators
If the link doesn't work, here's the raw url:
https://wiki.php.net/rfc/trailing_boolean_operators
The TL;DR is that we allow what I'm calling a 'dangling' ('optional' might
be the better word) trailing boolean operator. Mirroring trailing commas.
It's designed to be a purely additive QoL improvement to help reduce diffs.
I'm both excited and anxious to see what you all think of it.
Cheers,
Len
Hi everyone,
I think I've got this RFC into the expected state needed to announce it and
open discussion.Trailing Boolean Operators
https://wiki.php.net/rfc/trailing_boolean_operatorsIf the link doesn't work, here's the raw url:
https://wiki.php.net/rfc/trailing_boolean_operatorsThe TL;DR is that we allow what I'm calling a 'dangling' ('optional' might
be the better word) trailing boolean operator. Mirroring trailing commas.
It's designed to be a purely additive QoL improvement to help reduce diffs.I'm both excited and anxious to see what you all think of it.
Cheers,
Len
I do not see the lack of trailing (dangling) operators as inconsistent
with trailing commas. Commas aren't operators. Commas don't have
precedence. They don't affect program flow like boolean operators. I
think trailing boolean operators could be dangerous in very sneaky and
nuanced ways.
If you're concerned about diffs, put the boolean operators at the front:
if (
$order->isPaid()
&& $order->isShipped()
&& $order->isDelivered()
) {
$order->archive();
}
Now, you can add more to the if statement without having a cumbersome
diff. However, I would recommend reworking and simplifying the logic
instead. The more boolean operators you add, the higher the cognitive
complexity, and the more complicated your test cases are for this code path.
I would vote "no" on this RFC.
Cheers,
Ben