Re: Use declaration outside of namespace

From: Date: Wed, 29 Oct 2014 14:20:07 +0000
Subject: Re: Use declaration outside of namespace
References: 1 2 3 4  Groups: php.standards 
Request: Send a blank email to standards-+get-532@lists.php.net to get a copy of this message
> On Oct 29, 2014, at 9:04 AM, Chris Wright <cw@daverandom.com> wrote: > > It does, this example does indeed place something *outside* a namespace, > and I am quite surprised that PHP doesn't bork at this already. I would > hope no-one would ever write code like this anyway, but I'm sure I would be > disappointed. > I write scripts all the time that I run from the command line, and these use namespaces but do not specify a namespace of their own. So, these use statements are *outside* a namespace. Are you saying this is incorrect to do? For example: <?php require_once 'vendor/autoload.php'; use Foo\Bar; $bar = new Bar(); $bar->doSomethingWithBar(); ?>

« previous php.standards (#532) next »