Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 68338 invoked from network); 13 Dec 2017 05:05:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2017 05:05:07 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; 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:48043] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/B8-53433-005B03A5 for ; Wed, 13 Dec 2017 00:05:05 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id 1F04B2984238 for ; Wed, 13 Dec 2017 06:05:01 +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 AB6wyQri2LdV for ; Wed, 13 Dec 2017 06:04:57 +0100 (CET) Received: from mail-ot0-f182.google.com (unknown [74.125.82.182]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id F27102984233 for ; Wed, 13 Dec 2017 06:04:56 +0100 (CET) Received: by mail-ot0-f182.google.com with SMTP id b54so998030otd.8 for ; Tue, 12 Dec 2017 21:04:56 -0800 (PST) X-Gm-Message-State: AKGB3mJoEg8oIyup5I2nRc7TObB5n5cN4IjxJyYlqp7TopMBjQa1oS0k UeU/s2WPBAa3APNm+SKNvd9qoGrpS2gOsFtHc94= X-Google-Smtp-Source: ACJfBouT2Wjjqtf1GY/azgB9cuomiN+Ej+V/OBTCCgR2RP/ovn0HbyTpG0CIG8KeXvRtAfoiawzi3MBTCPlPhGr703s= X-Received: by 10.157.89.230 with SMTP id u38mr1017212otg.270.1513141495974; Tue, 12 Dec 2017 21:04:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.46.70 with HTTP; Tue, 12 Dec 2017 21:04:55 -0800 (PST) In-Reply-To: References: Date: Wed, 13 Dec 2017 06:04:55 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Andreas Hennings Cc: Nikita Popov , Stanislav Malyshev , PHP internals Content-Type: multipart/alternative; boundary="f4030435beb45cd115056031b583" Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --f4030435beb45cd115056031b583 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 2017-12-13 5:38 GMT+01:00 Micha=C5=82 Brzuchalski : > > > 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 >> should 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 lik= e: >> > src/Cat.php <-- class Acme\Animal\Cat >> > src/ns.php <-- that should be then a place for namespace declare or ev= en >> > 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 >> > Actually not true. `namespace` keyword is reserved and none class can have such name. This means this example couses a syntax error: > 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: > > > namespace_declare('Acme\Animal', [ > 'strict_types' =3D> 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. >> > > > > -- > regards / pozdrawiam, > -- > Micha=C5=82 Brzuchalski > about.me/brzuchal > brzuchalski.com > --=20 regards / pozdrawiam, -- Micha=C5=82 Brzuchalski about.me/brzuchal brzuchalski.com --f4030435beb45cd115056031b583--