Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78894 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10602 invoked from network); 13 Nov 2014 12:40:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Nov 2014 12:40:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:43660] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/32-29190-0B6A4645 for ; Thu, 13 Nov 2014 07:40:16 -0500 Received: (qmail 31743 invoked from network); 13 Nov 2014 13:40:11 +0100 Received: from 77.119.128.93.wireless.dyn.drei.com (HELO RoLaptop) (77.119.128.93) by ns73.kreativmedia.ch with ESMTPSA (AES256-SHA encrypted, authenticated); 13 Nov 2014 13:40:11 +0100 To: "'Chris Wright'" , =?utf-8?Q?'Johannes_Schl=C3=BCter'?= Cc: "'Adam Harvey'" , "'PHP Internals'" References: <000201cff3b2$37615e50$a6241af0$@tutteli.ch> <001101cffda8$9f56e980$de04bc80$@tutteli.ch> <001a01cffebf$76f5c2a0$64e147e0$@tutteli.ch> <1415878147.11005.1.camel@kuechenschabe> In-Reply-To: Date: Thu, 13 Nov 2014 13:40:08 +0100 Message-ID: <001c01cfff3e$f6344670$e29cd350$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIPPXtbPZBTwayAd3/waoyNKhChzAEtjs3+AdXjotIBhDhuxANAm77fAhwlQfabkN0bYA== Content-Language: de-ch Subject: AW: AW: [PHP-DEV] forbid use declaration outside of a namespace in PHP 7 From: php@tutteli.ch ("Robert Stoll") > -----Urspr=C3=BCngliche Nachricht----- > Von: are.you.winning@gmail.com [mailto:are.you.winning@gmail.com] Im = Auftrag von Chris Wright > Gesendet: Donnerstag, 13. November 2014 13:13 > An: Johannes Schl=C3=BCter > Cc: Robert Stoll; Adam Harvey; PHP Internals > Betreff: Re: AW: [PHP-DEV] forbid use declaration outside of a = namespace in PHP 7 >=20 > On 13 November 2014 11:29, Johannes Schl=C3=BCter = wrote: >=20 > > 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 =3D 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? [Robert Stoll]=20 I share Chris' statement. Combining multiple files would only work if = they all use namespace blocks or if they do not use any namespaces at = all (and thus are implicitly in the default namespace). >=20 > 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: >=20 > =20 > use \Foo; > namespace Bar; >=20 > 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). >=20 [Robert Stoll]=20 I think it would be wrong to start to do such auto-fixes. Syntax which = is wrong should emit a fatal error IMO (assuming we would disallow = use-statement outside of a namespace). In this case the user has to move = the statement down a few lines and it works again. Better than = auto-fixing which might introduce unintended bugs. >=20 > johannes > > > > > > -- > > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, > > visit: http://www.php.net/unsub.php > > > >