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
--TEST--
034: Namespace import function across files
--FILE--
<?php
include 'ns_033.php';
import foo::foobar;
foobar();
--EXPECT--
foo::foobar
--TEST--
035: Namespace import function alias across files
--FILE--
<?php
include 'ns_033.php';
import foo::foobar as foobat;
foobat();
--EXPECT--
foo::foobar
<?php
namespace foo;
// include for namespace tests across files
class Foobaz {
function __construct() {
echo __CLASS__, "\n";
}
}
function foobar() {
echo __FUNCTION__, "\n";
}
--TEST--
033: Namespace import across files
--FILE--
<?php
include 'ns_033.php';
import foo;
foobar();
new Foobaz;
--EXPECT--
foo::foobar
foo::Foobaz
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php