Re: Scoping of "use" statements and a strategy for 5.3/6.0 release of namespace
| From: | Greg Beaver | Date: | Thu, 11 Sep 2008 17:02:08 +0000 |
| Subject: | Re: Scoping of "use" statements and a strategy for 5.3/6.0 release of namespace | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-40472@lists.php.net to get a copy of this message | ||
Stan Vassilev | FM wrote:
> Hi,
>
> Multiple namespaces per file were introduced to allow certain
> workflows in PEAR and frameworks like Symphony which can combine
> multiple classes and namespaces in a single package.
>
> They work like this:
>
>
> namespace X;
>
> ...
>
> namespace Y;
>
> ...
>
>
> The problem is, no one thought of scoping "use" statements, so now
> those merged files share their "use" imports, thus breaking all the
> code where collisions occur.
Hi,
Stan, did you actually try this out? According to my checkout of CVS,
you're wrong. Try this script:
<?php
namespace one;
class one {
static function hi(){echo "hi\n";}
}
one::hi();
namespace two;
use one::one;
one::hi();
namespace three;
one::hi();
?>
The output is:
hi
hi
Fatal error: Class 'three::one' not found in
/home/user/workspace/php5_func/test.php on line 11
Greg