# [RFC] Trailing Boolean Operators

- Thread: https://externals.io/message/129996
- Original archive: https://news-web.php.net/php.internals/129996
- Started by Len Woodward on 2026-02-03T19:05:47+00:00
- Messages: 7
- RFC: Trailing Boolean Operators (Under discussion) — https://externals.io/rfc/trailing_boolean_operators.md
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · RFCs at https://externals.io/rfc.md · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #129996 — Len Woodward — 2026-02-03T19:05:47+00:00

URL: https://externals.io/message/129996#129996

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

---

## #129998 — Ben Ramsey — 2026-02-04T01:13:17+00:00

URL: https://externals.io/message/129996#129998 · In reply to: #129996

> 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

---

## #130000 — Ben Ramsey — 2026-02-04T01:57:34+00:00

URL: https://externals.io/message/129996#130000

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

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

https://pandoc.org/ 

> 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

---

## #130003 — Ayesh Karunaratne — 2026-02-04T08:23:40+00:00

URL: https://externals.io/message/129996#130003 · In reply to: #129996

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

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.

---

## #130004 — tim@bastelstu.be — 2026-02-04T09:51:02+00:00

URL: https://externals.io/message/129996#130004 · In reply to: #129996

Hi

Am 2026-02-03 20:05, schrieb Len Woodward:
> If the link doesn't work, here's the raw url:
> https://wiki.php.net/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: 
https://www.php-fig.org/per/coding-style/#51-if-elseif-else

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

---

## #130005 — tim@bastelstu.be — 2026-02-04T10:07:34+00:00

URL: https://externals.io/message/129996#130005 · In reply to: #130004

Hi

Am 2026-02-04 10:51, schrieb Tim Düsterhus:
> > […]
> 
> 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: 
https://github.com/php/policies/blob/main/feature-proposals.rst#required-majority

Best regards
Tim Düsterhus

---

## #130017 — Seifeddine Gmati — 2026-02-05T13:36:00+00:00

URL: https://externals.io/message/129996#130017 · In reply to: #129996

>
> 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
<https://github.com/carthage-software/mago>), I can attest that supporting
this would be non-trivial. PHP's operator precedence/associativity is
already quite a mess (reference
<https://github.com/carthage-software/mago/blob/main/crates/syntax/src/parser/internal/expression.rs#L738-L797>),
and introducing trailing boolean operators adds parsing complexity without
providing proportional value to the language.

Cheers,
Seifeddine.
