Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78893 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8891 invoked from network); 13 Nov 2014 12:30:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Nov 2014 12:30:57 -0000 Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; 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:41277] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 68/E1-29190-084A4645 for ; Thu, 13 Nov 2014 07:30:57 -0500 Received: (qmail 27123 invoked from network); 13 Nov 2014 13:30:52 +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:30:52 +0100 To: "'Rowan Collins'" , References: <000201cff3b2$37615e50$a6241af0$@tutteli.ch> <001101cffda8$9f56e980$de04bc80$@tutteli.ch> <001a01cffebf$76f5c2a0$64e147e0$@tutteli.ch> <54648E94.5060802@gmail.com> In-Reply-To: <54648E94.5060802@gmail.com> Date: Thu, 13 Nov 2014 13:30:49 +0100 Message-ID: <001b01cfff3d$a8fc7900$faf56b00$@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+AdXjotIBhDhuxACRyOZdm7cxEDA= 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: Rowan Collins [mailto:rowan.collins@gmail.com] > Gesendet: Donnerstag, 13. November 2014 11:57 > An: internals@lists.php.net > Betreff: Re: AW: [PHP-DEV] forbid use declaration outside of a = namespace in PHP 7 >=20 > Robert Stoll wrote on 12/11/2014 21:27: >=20 > > 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. >=20 > Surely if that's true of Adam's example, it's true of yours as well? [Robert Stoll]=20 The difference is that I have specified a namespace and thus code = outside of that namespace is no longer implicitly in the default = namespace. > > namespace a{ > > } > > > > use some\UseDeclaration\which\is\outside\of\AnyNamespace as Useless; > > // sorry for begin biased ^^ > > > > namespace test{ > > } >=20 > 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. [Robert Stoll]=20 Same applies here, my use statement is outside of a namespace Adam's = isn't. > For that matter, what about this: >=20 > use GuzzleHttp\Client; >=20 > include __DIR__.'/vendor/autoload.php'; >=20 > $client =3D new Client; > // $client is a GuzzleHttp\Client object >=20 > namespace Foo; > $client =3D new Client; > // $client is a Foo\Client object >=20 > 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. >=20 > Regards, > -- > Rowan Collins > [IMSoP] >=20 [Robert Stoll] I haven't tested it I am pretty sure this script would fail since = $client =3D new Client is outside of a namespace - an error message = something like "namespace must be the first statement" would show up. If I rewrite your code to the following: namespace{ use GuzzleHttp\Client; =20 include __DIR__.'/vendor/autoload.php'; =20 $client =3D new Client; // $client is a GuzzleHttp\Client object =20 namespace Foo{ $client =3D new Client; // $client is a Foo\Client object } Then it would make sense (use statement is inside a namespace).