Hello internals,

I’d like to propose adding with as a full alias for the namespace-related
use keyword in PHP. This is a purely syntactic improvement aimed at:

   1. Clarifying semantics: with better conveys "reference/borrow" intent
   (e.g., with Foo\Bar vs. use Foo\Bar).
   2. Reducing beginner confusion: use currently serves dual roles
   (namespaces and closure captures), which can be misleading.
   3. Aligning with modern languages: Similar keywords exist in Dart/Kotlin
   (with/import).

Key points:

   - Zero-cost: Lexer-level alias, no runtime impact.
   - Fully backward compatible: use remains permanently supported.

Example:

php


// Current syntax  use Vendor\Package\ClassName;  use function
Vendor\Package\functionName;
// Proposed syntax
with Vendor\Package\ClassName;
with function Vendor\Package\functionName;

Question to the list:

   - Does this improvement warrant an RFC?
   - Are there objections to the concept or keyword choice?

I’ll proceed with a formal RFC if feedback is non-negative. Appreciate your
thoughts!
------------------------------

Proposed by: [xiaoma]
GitHub: [https://github.com/15892951523]

Reply via email to