RE: [PHP-DEV] Simple Namespace Proposal

From: Date: Mon, 23 Jul 2007 09:26:09 +0000
Subject: RE: [PHP-DEV] Simple Namespace Proposal
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-31177@lists.php.net to get a copy of this message
Hi Arpad, You have to always use namespace name as prefix for acesing namespace entities. (The only exception is direct import of calss). So expectatins in your tests are wrong. Thanks. Dmitry. > -----Original Message----- > From: Arpad Ray [mailto:arpad@rajeczy.com] > Sent: Sunday, July 15, 2007 7:32 PM > To: Dmitry Stogov > Cc: 'Hans Lellelid'; 'PHP internals' > Subject: Re: [PHP-DEV] Simple Namespace Proposal > > > 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 >

« previous php.internals (#31177) next »