On Sat, Mar 15, 2025, at 00:21, Rowan Tommins [IMSoP] wrote: > On 05/03/2025 23:11, Rob Landers wrote: > > > > I'd like to introduce my RFC for discussion: > > https://wiki.php.net/rfc/short-and-inner-classes > > > As a user, I find the concept of inner classes quite confusing. > > However, I was looking at some code earlier and thought an "inner enum" > would be useful, to replace various "MODE_FOO" type class constants - > but I see those are left to future scope. :(
Actually, it appears I did not limit it in the implementation... So, maybe we could play with it and see what breaks. I simply left traits, enums, and interfaces to future scope because 1) I didn't have a working implementation yet, 2) had no idea what would break and 3) every time someone suggests a change to enums, the discussion explodes. Having inner enums, traits, and interfaces is actually quite simple. Might as well see how simple. :) But fwiw, I do plan on a near immediate RFC(s) for these if this thing passes, as well as short classes -- I also have a semi-finished draft with short enums as well, but that one is actually physically impossible without making 'enum' a true reserved word. The "hack" (if you will) to bypass that requirement is still in place and makes the grammar (likely) impossible. I will have to fix this tomorrow, because I am not a fan of having inner classes on interfaces, at least. I will play with it on enums and traits and see what breaks. I suspect inner classes on traits will cause utter chaos. > I'm aware they exist in a lot of other languages, though, so I thought > I'd look around at how the proposed version compares. It seems there's > quite a zoo out there... > > One common theme I do note is that all four of the pages I found are > titled "nested classes" or "nested types"; in some cases, "inner > class"/"inner type" has a specific meaning, which I don't think matches > the RFC's proposal. I actually borrowed heavily from C#. I'm familiar with its usage and rules, and it fits nicely with PHP paradigms. — Rob