Re: [RFC] Pipe to return
| From: | Tim Düsterhus | Date: | Tue, 03 Feb 2026 15:13:26 +0000 |
| Subject: | Re: [RFC] Pipe to return | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-129995@lists.php.net to get a copy of this message | ||
Hi
Am 2026-01-31 06:52, schrieb Vadim Dvorovenko:
Introducing Pipe to return RFC
https://wiki.php.net/rfc/pipe_to_return
In short, RFC proposes piping expression result to return to be used together with pipe operator to reduce cognitive load
Thank you for your RFC. I appreciate how well-written it is and how carefully you followed the suggested template.
That said, I agree with the others that I find the proposal a step backwards in terms of readability. Having the return at the start of the line is a clear indicator that the function ends there and it is only a “single bit” of information I have to keep in mind while I continue reading until I find the semicolon ending the statement. It is also consistent with how assignments - the other primary use case for pipes - start with the target variable and the equals before the “pipe expression”. I think it would not be wrong to think of return as “assigning to the return value”.
While it is true that no one is forced to use the new syntax, I will inevitably come across it in libraries that decide to use it, thus I will be forced to know that it is a thing and to understand what it does. And of course all IDEs and static analyzers will need to learn about it as well.
For these reasons, I don't believe it meets the cost-benefit ratio.
Best regards
Tim Düsterhus