Re: AW: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7
| From: | Rowan Collins | Date: | Thu, 13 Nov 2014 10:57:24 +0000 |
| Subject: | Re: AW: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-78890@lists.php.net to get a copy of this message | ||
Robert Stoll wrote on 12/11/2014 21:27:
That's still perfectly fine because in your code the use statement is not outside of a namespace, it is implicitly in the default namespace.Surely if that's true of Adam's example, it's true of yours as well?
namespace a{ } use some\UseDeclaration\which\is\outside\of\AnyNamespace as Useless; // sorry for begin biased ^^ namespace test{ }This scenario looks identical to Adam's to me, unless you propose to look at the entirety of the file to detect if there is something other than a use statement in the default namespace. For that matter, what about this: use GuzzleHttp\Client; include __DIR__.'/vendor/autoload.php'; $client = new Client; // $client is a GuzzleHttp\Client object namespace Foo; $client = new Client; // $client is a Foo\Client object Certainly this code is not *sensible*, but it does have a meaningful behaviour, which derives directly from the previous examples and documented uses of the namespace keyword. I'm not sure how you'd distinguish between the various combinations here. Regards, -- Rowan Collins [IMSoP]