Alias Conflicts

../_images/aliasConflicts.png

When the class is defined before the alias, the alias fails as the class already uses the name. When the class is defined after the alias, the class fails, although only if the class is in the same physical namespace block as the use.

This illustration is good to show and tell, but in real life, it never happens. On the contrary, the classes and uses are in different files, and the order of loading is controller by code execution, via autoloading.

This means that reusing a namespace’s class name as an alias is prone to random failures, depending on the inclusions.

As a side note, the use command does not need the definition of the original, until actual usage.

See Also

PHP Features