[RFC] use-from syntax for namespace use declarations
| From: | Stuardo -StR- Rodríguez | Date: | Tue, 06 Jan 2026 02:14:03 +0000 |
| Subject: | [RFC] use-from syntax for namespace use declarations | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-129738@lists.php.net to get a copy of this message | ||
Hello internals,
I am writing to open the discussion for the RFC "use-from syntax for
namespace use declarations":
https://wiki.php.net/rfc/use-from
This proposal introduces an alternative syntax for namespace imports:
```php
use Name from Prefix;
use {A, B} from Prefix;
```
This form is purely syntactic sugar for the traditional
use Prefix\Name;
syntax. The primary motivation is to improve readability and ergonomic
sorting of imports by placing the imported symbol name first (e.g. `use
User from App\Models`), similar to import styles in other languages like
Python or JavaScript.
The implementation introduces from as a contextual keyword in use
declarations, ensuring backward compatibility for existing uses of from
as method names or identifiers.
You can find the proof-of-concept implementation here:
https://github.com/php/php-src/pull/20844
I look forward to your thoughts and feedback.
Best regards,
Stuardo Rodríguez
str@maphpia.com
--
Stuardo Rodríguez Mercenary Web Developer La Maphpia
🌎 maphpia.com ✉ str@maphpia.com 📞 +502 3462-7169