Re: Re: 回复: [PHP-DEV] [RFC] Proposal namespace importing with from syntax
Hi:
is there any really usage? I didn't see before. I don't think every
python feature is proper for PHP. PHP is not python.
-1 on this RFC
+1 for Stas
and one more thing, BC break.
there are many ORM or DB warpper libraries defines from
method, like:
$db->select()->from();
thanks
On Wed, Jul 25, 2012 at 1:22 PM, Stas Malyshev <[email protected]> wrote:
> Hi!
>
>> No, we can not import namespace directly for now :
>
> Of course you can. You just missing on what namespace import means in
> PHP, it's not like Java (though a bit like Python).
>
>> <?php
>> namespace A {
>> class B {}
>> }
>>
>> namespace {
>> use A;
>>
>> var_dump(new B());
>> }
>
> use A is a no-op, just as the warnings tell you. You can just write A\B.
> It's only 2 characters more. If your A is longer, then you can alias it
> to something shorter.
>
>> and if we need alias we could:
>> <?php
>> // reduce
>> use GlobalNamespace\SubSpace\ThirdSpace\Class1;
>> use GlobalNamespace\SubSpace\ThirdSpace\Class2 as Alias2;
>> use GlobalNamespace\SubSpace\ThirdSpace\ForthSpace\Class3 as Alias3;
>
> You could just do
> use GlobalNamespace\SubSpace\ThirdSpace as Spc;
> $a = new Spc\Class1();
>
>
> --
> Stanislav Malyshev, Software Architect
> SugarCRM: http://www.sugarcrm.com/
> (408)454-6900 ext. 227
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--
Laruence Xinchen Hui
http://www.laruence.com/
Thread (11 messages)