Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101345 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63287 invoked from network); 13 Dec 2017 04:38:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2017 04:38:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:41635] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/18-53433-ACEA03A5 for ; Tue, 12 Dec 2017 23:38:35 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 33AB92984233 for ; Wed, 13 Dec 2017 05:38:32 +0100 (CET) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CZESKOq7qGFm for ; Wed, 13 Dec 2017 05:38:30 +0100 (CET) Received: from mail-ot0-f176.google.com (unknown [74.125.82.176]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id 0F23B2984236 for ; Wed, 13 Dec 2017 05:38:28 +0100 (CET) Received: by mail-ot0-f176.google.com with SMTP id d27so958228ote.11 for ; Tue, 12 Dec 2017 20:38:27 -0800 (PST) X-Gm-Message-State: AKGB3mLv/D6BW1C2CGrYOagMFaeiyJqrPVK+K+hE7hIRSBlg2RiZoMD+ H3vCXBid4mJIX+E0rs2yLVEPnZxTMut8mm57Jw8= X-Google-Smtp-Source: ACJfBov2+Fm+omdIBCkQDaMEp6lvz1Lah4Sht95J3jQvVEKaa7hOKxEoC+s9Y0OpZhb+iXa7KfsKexfdAvDfUCtOZCo= X-Received: by 10.157.89.173 with SMTP id u45mr1063210oth.341.1513139907024; Tue, 12 Dec 2017 20:38:27 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.46.70 with HTTP; Tue, 12 Dec 2017 20:38:26 -0800 (PST) In-Reply-To: References: Date: Wed, 13 Dec 2017 05:38:26 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Andreas Hennings Cc: Nikita Popov , Stanislav Malyshev , PHP internals Content-Type: multipart/alternative; boundary="94eb2c1e9930a75c92056031560a" Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --94eb2c1e9930a75c92056031560a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2017-12-13 5:24 GMT+01:00 Andreas Hennings : > On 13 December 2017 at 05:04, Micha=C5=82 Brzuchalski > wrote: > > > > If we're going to introduce someday a namespace file, then IMO it shoul= d > not > > be putted outside namespace folder. > > For eg class Acme\Animal\Cat in src/Acme/Animal/Cat.php should have > > namespace file in src/Acme/Aniimal/namespace.php > > or even more src/Acme/Animal/ns.php > > Why? Because users use PSR-4 so then they're src folder looks more like= : > > src/Cat.php <-- class Acme\Animal\Cat > > src/ns.php <-- that should be then a place for namespace declare or eve= n > > function and constants. > > You are right, my previous proposal src/Acme/Animal.namespace.php > would not work universally. > > But your proposal, src/Acme/Animal/ns.php clashes with the class file > for class \Acme\Animal\ns. > > We would need something other than NAME.php. > E.g. src/Acme/Animal/ns.inc.php > > But then Composer would still need to make sure that this file is > always included before any class files from this directory. > On language level we cannot assume that Composer is being used, and > that it is being used correctly. > > So again this would be fragile. > > > > > Such namespace file can be a good place for namespace function and > constants > > declaration. > > Also I think there is no need for another global function named > > `namespace_declare` if we had namespace file > > then we can utilise declare for that. > > Lets imagine such syntax: > > > > // src/Acme/Animal/ns.php > > > > > namespace Acme\Animal declare(strict_types=3D1,another_option=3D0); > > const CAT =3D 1; > > function createCat() : Cat {} > > This means you are changing the meaning of existing declare() to apply > to the entire namespace? > Or to the entire directory? > > To entire namespace just like: 1, 'dynamic_object_properties' =3D> 0, ... ]); namespace Acme\Animal declare( strict_types=3D1, dynamic_object_properties=3D0 ); // <-- this works same as namespace_declare call above namespace Acme\Machines { // here we have strict_types=3D0 turned off } > Or maybe the difference here is that there is no semicolon directly > after the namespace declaration? > > I am not convinced by this syntax. > But even if we would find a good syntax, the behavioral problems > pointed out by Stanislav still apply. > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --94eb2c1e9930a75c92056031560a--