[PHP-DEV] [RFC] Trailing Boolean Operators

Hi everyone,

I think I’ve got this RFC into the expected state needed to announce it and open discussion.

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

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
<PHP: rfc:trailing_boolean_operators;

If the link doesn't work, here's the raw url:
PHP: 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

This message went directly to me instead of the list, so I’ve added the list back to my reply.

On Feb 3, 2026, at 19:35, Len Woodward <len@artisan.build> wrote:

I had originally written this RFC in markdown, and when I had claude migrate it for the wiki it discarded a whole section I had in there about simply using leading operators instead. I've added that back in and tagged a minor change.

Pro-tip: pandoc can do Markdown-to-Dokuwiki conversion in a deterministic way, so you don’t have to worry about LLMs generating slop.

    pandoc -f markdown -t dokuwiki my-doc.md

The gist of the argument against simply using leading operators instead is that it doesn't solve the problem -- It just moves it. There's always going to be a special reordering case.

I see this as a feature and not a bug. Boolean operators control program flow. Whenever you add a new condition, you should have to think about reordering (because you might really need to reorder the conditions), or you should consider splitting up the logic so that it is more maintainable.

ps. When replying to the thread, I know I'm supposed to respond underneath the previous content, but am I supposed to keep the entire history, or just the previous message? I'm rereading the policies and the rfc:howto, and I can't find that section.

Yes, you may truncate the original message and weave your reply between quotes, as I’ve done in this reply.

Cheers,
Ben

Trailing Boolean Operators

If the link doesn't work, here's the raw url:
PHP: 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.

Hi Len,
I see that this is your first RFC, welcome, and well done on the RFC
draft. The RFC text is quite detailed, and clearly brings the idea
across. I appreciate that you explained your rationale, with simple
examples, and a well-defined scope. Greatly done.

As for the idea, however, I do not agree that this would be a
net-positive change. I wanted to echo what Ben said in his reply too.

Commas are fundamentally different from the operators like `&&` and
`||`. One is a separator, the other is an operator. Trailing
separators do not add to the confusion, and the benefits you mention
in the RFC are meaningful improvements that do not add to visual
confusion.

`&&` and `||` are binary operators that require a right-hand operand.
Your RFC removes this requirement from the syntax, but I believe they
semantically still require a right-hand operand.

I'm also not aware of any other languages that allow trailing
operators. For PHP to add trailing commas, it had a strong argument in
favor because other languages like JavaScript, Python, and of course C
(among many other languages) supported it, and adding support for
trailing commas was a natural progression. Back then, even this was
argued quite a lot in the RFC discussions, and some proposals did not
pass the vote.

As Ben mentioned, the new-line, operator, and operand pattern solves
the diff issue. Besides, changing the order of an `if` block is a
significant change, and at least for me, not something I do often. For
changes like this, I would rather like it to have a more visually
stark diff.

Thanks,
Ayesh.

Hi

Am 2026-02-03 20:05, schrieb Len Woodward:

If the link doesn't work, here's the raw url:
PHP: rfc:trailing_boolean_operators

Thank you for the RFC. I second Ayesh's remark with how well-written the RFC is. I have one minor housekeeping note: The Status in the RFC itself is still set to “Draft”.

With regard to the “Trailing-Operator Style is Established” section, I'd like to note that the latest edition of the “Code Style published by PHP FIG” is the PER Coding Style 3.0 which requires the boolean operators at the start of the line: PER Coding Style 3.0 - PHP-FIG

Other than that, I share the concerns that have already been voiced in this thread and thus won't repeat them.

Best regards
Tim Düsterhus

Hi

Am 2026-02-04 10:51, schrieb Tim Düsterhus:

If the link doesn't work, here's the raw url:
PHP: rfc:trailing_boolean_operators

Thank you for the RFC. I second Ayesh's remark with how well-written the RFC is. I have one minor housekeeping note: The Status in the RFC itself is still set to “Draft”.

Ah. One more thing: The voting widget is missing the “Abstain” option. I just added it in myself, since it's a clear policy requirement. See: policies/feature-proposals.rst at main · php/policies · GitHub

Best regards
Tim Düsterhus

On Tue, 3 Feb 2026 at 20:07, Len Woodward len@artisan.build wrote:

Hi everyone,

I think I’ve got this RFC into the expected state needed to announce it and open discussion.

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 Len,

Thank you for the proposal, and congratulations on your first RFC!

However, I am not in favor of this specific change. Unlike commas, which serve as separators, binary operators functionally demand a right-hand operand. Allowing a trailing operator breaks this fundamental expectation and introduces unnecessary ambiguity.

As a maintainer of a handwritten PHP parser (mago), I can attest that supporting this would be non-trivial. PHP’s operator precedence/associativity is already quite a mess (reference), and introducing trailing boolean operators adds parsing complexity without providing proportional value to the language.

Cheers,
Seifeddine.