On Mon, Jun 29, 2026, at 5:32 PM, Michal Kral wrote: > Hi all, > > Per Seifeddine's suggestion to keep this out of the karma-request > thread, I'm opening a pre-RFC discussion for scalar object methods -- > 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.
It may seem odd coming from me, but I am not in favor of scalar methods. Specifically because of this line: > small, curated set of methods That is bikeshed bait, and needlessly limiting. I would not support that. What we should do instead is take a cue from Kotlin and C#: Extension functions. Attach method-ish behavior to *any* type. Sara Golemon and I worked up an idea of how it could work (with lots of "we could spell it X, or Y, or Z" bits still in there) a while ago, though I've not done anything with it since. (Plenty else to do.) The writeup is here: https://gist.github.com/Crell/84cab7c3bf2b25e81b7f464945f6b678 I think that is a much better approach to take, and would be happy to work on it if someone wants to partner on it. (Though it's definitely not getting into 8.6 at this point, obviously.) --Larry Garfield
