[RFC] Proposal namespace importing with from syntax
| From: | Reeze | Date: | Tue, 24 Jul 2012 15:35:03 +0000 |
| Subject: | [RFC] Proposal namespace importing with from syntax | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-61691@lists.php.net to get a copy of this message | ||
Hi, internals,
I'm proposing a improvement to namespace importing. when using 'use' statement to
import
many classes, we have to duplicate many times even we are importing from the same namespace.
I propose a new syntax to import classes\functions\constant in a single statement.
here is the example:
<?php
// reduce
use GlobalNamespace\SubSpace\ThirdSpace\Class1;
use GlobalNamespace\SubSpace\ThirdSpace\Class2;
use GlobalNamespace\SubSpace\ThirdSpace\ForthSpace\Class3;
// to
from GlobalNamespace\SubSpace\ThirdSace use Class1, Class2 as Alias2, ForthSpace\Class3 as Alias3;
?>
The above code should be self-explained.
More info could be found at the RFC page and the patch.
RFC: https://wiki.php.net/rfc/namespace-importing-with-from
PATCH : https://github.com/reeze/php-src/compare/rfc-from-use
Any Opinion, suggestion, improvement will be much appreciated.
Thanks
--
reeze | http://reeze.cn