I've been using PHP's namespaces for some time now and I think it is a great addition to my programming. This morning I wondered about something concerning the use
statement. I'm wondering if the order of use
affects the functonality of my PHP code.
According to PHP.net
The ability to refer to an external fully qualified name with an alias, or importing, is an important feature of namespaces. This is similar to the ability of unix-based filesystems to create symbolic links to a file or to a directory.
AIn PHP, aliasing is accomplished with the use operator.
~ That sucks, nothing about the order of inclusion. Let's ask my friends on SO!
Example
Below, I'll try to give a better example
Class C
namespace Fully\Qualified\Namespace;
use Fully\Qualified\Namespace\B;
use Fully\Qualified\Namespace\A;
class C
{
// ...
}
Class B
namespace Fully\Qualified\Namespace;
use Fully\Qualified\Namespace\A;
class B extends A
{
// ...
}
Class A
namespace Fully\Qualified\Namespace;
class A
{
// ...
}
Now, will it give me trouble that class B
is included before class A
in my use statements?