On 5/24/25 04:49, Rowan Tommins [IMSoP] wrote:
On 24 May 2025 10:08:46 BST, "马正强" <a766650...@gmail.com> wrote:Hello internals, I’d like to propose adding with as a full alias for the namespace-related use keyword in PHP....- Does this improvement warrant an RFC? - Are there objections to the concept or keyword choice?It would certainly need an RFC in order to add, because it's a core language change. Adding a new keyword generally requires reserving it in at least some contexts, so the backward compatibility impact would need to be made clear in any RFC as well. Personally, though, I don't see any advantage at all. Both keywords seem equally arbitrary, and the existing syntax has been established for over a decade at this point. Having two ways to write the same thing is likely to confuse new users about whether they do different things, and there won't be any incentive for existing code to change from one to the other, especially since they won't be able to for several years if they support multiple PHP versions. As for other languages, they use all sorts of different keywords for the same or similar features, e.g. "import" and "using", so it's not like PHP is a weird outlier here. Regards, Rowan Tommins [IMSoP]
I agree with Rowan that an additional `with` keyword as an alias of `use` would cause more confusion for users, rather than less.
I often run across users who assume that `use` has some kind of import semantics, like the `import` keyword in other languages, but in PHP, it's not much more than an alias for a fully-qualified class name. AFAIK, it doesn't do any actual work. I think `with` would add to the confusion, since it sounds (to my ears) like it implies an even tighter relationship to the concept of importing/including.
Cheers, Ben
OpenPGP_signature.asc
Description: OpenPGP digital signature