Re: [RFC] Trailing Boolean Operators

From: Date: Wed, 04 Feb 2026 01:13:17 +0000
Subject: Re: [RFC] Trailing Boolean Operators
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-129998@lists.php.net to get a copy of this message
On 2/3/26 13:05, Len Woodward wrote:
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
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

Attachment: [application/pgp-signature] OpenPGP digital signature OpenPGP_signature.asc
« previous php.internals (#129998) next »