I have got a single file in which I need specify classes in multiple namespaces, something like:
<?php
namespace library;
class ClassInLib {
...
}
namespace \; //Switch to root namespace
class ClassInRoot {
...
}
The above code has a syntax error at namespace \;. How can I switch from the library namespace to the root namespace?
Why do I need this: I need to mock a bunch of classes during unit testing and I don't think these very short mock classes justify being in separate files.
namespace
{
class RootClass
{
function whatever();
}
}
namespace Symfony\Component\DependencyInjection
{
interface ContainerAwareInterface
{
function setContainer(ContainerInterface $container = null);
}
}
http://www.php.net/manual/en/language.namespaces.definitionmultiple.php
Good chance you will decide to use separate files anyways.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With