On 13 November 2014 11:29, Johannes Schlüter <johan...@schlueters.de> wrote:
> On Wed, 2014-11-12 at 22:27 +0100, Robert Stoll wrote: > > > 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. > > I am talking about the two following scenarios: > > > > use \Exception; > > namespace test; > > > > $e = new Exception(); //would fails because test\Exception is unknown -> > use was defined outside the namespace > > > > > > Or > > namespace a{ > > } > > > > use some\UseDeclaration\which\is\outside\of\AnyNamespace as Useless; // > sorry for begin biased ^^ > > > > namespace test{ > > } > > If I get it rigth this might break code by people who, for whatever > reason, combine multiple PHP files into a single one. (cat *.php > > full.php && php full.php) > > This would only break if the individual files were already invalid. Files with namespace Name; style ns declarations couldn't be joined together in this way anyway, and files using namespace Name { ... } style declarations with use imports outside the block would be invalid on their own, concatenating them wouldn't break (or fix) this situation. Unless I missed something? I must say actually that while I think a use declaration outside a block-style namespace should be invalid, I'm about 50/50 on whether something like this should be invalid: <?php use \Foo; namespace Bar; The current behaviour is certainly wrong, but in this case it might be good to treat it as if the use declaration was after the ns declaration, rather than making it invalid (I haven't looked at how easy this would be to accomplish, though). johannes > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >