Re: Simple Namespace Proposal
| From: | Arpad Ray | Date: | Sun, 15 Jul 2007 15:31:51 +0000 |
| Subject: | Re: Simple Namespace Proposal | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-30950@lists.php.net to get a copy of this message | ||
Dmitry Stogov wrote:
> The patch is already committed to the HEAD.
>
> Dmitry.
>
There seem to be some problems with importing across files. The tests
currently in CVS are all in single files so it's not immediately
obvious. When a namespace is declared in one file and imported in
another, classes must be addressed absolutely either in the import or
when used, and functions must be addressed absolutely when used,
irrespective of imports.
I've attached some phpt files to test this, but here's a simple
illustration:
foo.php:
<?php
namespace foo;
function foobar() { }
class Foobaz { }
?>
bar.php:
<?php
import foo;
foobar(); // error
new Foobaz; // error
foo::foobar(); // ok
new foo::Foobaz; // ok
import foo::foobar;
import foo::Foobaz;
foobar(); // error
new Foobaz; // ok
import foo::foobar as foobar2;
foobar2(); // error
?>
Arpad