Re: [Pre-RFC] Scalar object methods (with a working implementation)
| From: | Morgan | Date: | Tue, 30 Jun 2026 11:56:58 +0000 |
| Subject: | Re: [Pre-RFC] Scalar object methods (with a working implementation) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131635@lists.php.net to get a copy of this message | ||
On 2026-06-30 10:32, Michal Kral wrote:
Hi all, calling a small, curated set of methods directly on scalar values, e.g. $str->trim(), (3)->pow(2). There's a complete, tested implementation and a full write-up (links below); I'd like to surface the strongest objections before I write the formal RFC. Larry Garfield has noted that when PFA lands, one would be able to write$s|>trim(?) One already has $s|>trim(...) but the ? syntax would allow $sep|>explode(?, $str) or $str|>explode($sep, ?) whichever seems more appropriate at the time. Probably not helpful for pre-existing functions (just say explode($sep, $string) already), but user functions might be more readable when pronounced this way..