Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101344 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61584 invoked from network); 13 Dec 2017 04:25:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Dec 2017 04:25:01 -0000 Authentication-Results: pb1.pair.com smtp.mail=andreas@dqxtech.net; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=andreas@dqxtech.net; sender-id=unknown Received-SPF: error (pb1.pair.com: domain dqxtech.net from 209.85.215.44 cause and error) X-PHP-List-Original-Sender: andreas@dqxtech.net X-Host-Fingerprint: 209.85.215.44 mail-lf0-f44.google.com Received: from [209.85.215.44] ([209.85.215.44:43351] helo=mail-lf0-f44.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D0/C7-53433-C9BA03A5 for ; Tue, 12 Dec 2017 23:25:01 -0500 Received: by mail-lf0-f44.google.com with SMTP id 94so1109550lfy.10 for ; Tue, 12 Dec 2017 20:25:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=5LI1LnBzsxodENGtnflYLk/XKwn36chmPENOUBqn/Tc=; b=xuozEi275ASk0ED7jb6dEX6FrHV8FwppfWhkqhEqkUB/mPz7PzTA+mzWO3g5j18SQk ibh7hdYwQBrM0yOpJl5qC/VlVzZPQsklGmfPJzgeSnhc8SZL7e98HI7TRuyuAJmkigBK d98I2jH2lpIqnpZHWdffGXhekqhV9Ph7fDRyedkJygdUvE9cnZtpTV9wKP0atYR/NEhw McDV4hr8Xhl2QBm1NeHsweYqFPTxSawH5Kpm8qIiojNAirgiJZdztoO6xHm0o4GSXrhj Z0myfR6nnW0rI+5kIDneB3c6W4PKzwPppVbbN2q6EQYuKXmn5INHUPdAgNRCebmVG3dE qaPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=5LI1LnBzsxodENGtnflYLk/XKwn36chmPENOUBqn/Tc=; b=KMh4b/jeVq9Cza3k4Xf/Gz6KDwWYq/FbiIVz7zlssvbJlyNGATar+B7043hf3U8NeU qog1ZAc0DTD8hEL/ciS0oaFNjGLCM4Kf7q3uIunWQVUIIt709XSEcQ3oNqIAMhzruAQe B3Z7/G4txBf58l9fwBdgZTk88agVtgnF+u0mzvFLt4paB7V1Srit+AOSpytIMA+EwWw8 oYVLBBcUyHsHSlaxowILd8oBgtYu0qLN2jsxyk1VeGYwrrebq/MthwyMBzVrOoW8Telh jH9jhu4fVScJpXw/86aaMAiThPac4zB/mscQhWI2F46ys9wCst2qylyBrmy0/DxTJr6K /xUQ== X-Gm-Message-State: AKGB3mJ5/Q9HmGO07xwfm8hfk5AoKUzOncnqre3ge9cP1Izdnj8F9Q44 1Clgf3pw+fDmTf8LLSnjq9eC9fPa X-Google-Smtp-Source: ACJfBosLHKJ7ozGPv5pWd87DfBuQkx+hQDM2QWzPJEp0v/0B7/IJbQvrw5GnUTBqOnkKA3pav8c73g== X-Received: by 10.46.25.85 with SMTP id p82mr646672lje.29.1513139096878; Tue, 12 Dec 2017 20:24:56 -0800 (PST) Received: from mail-lf0-f51.google.com (mail-lf0-f51.google.com. [209.85.215.51]) by smtp.googlemail.com with ESMTPSA id n10sm128723lfn.71.2017.12.12.20.24.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 20:24:56 -0800 (PST) Received: by mail-lf0-f51.google.com with SMTP id l81so1124264lfl.6 for ; Tue, 12 Dec 2017 20:24:55 -0800 (PST) X-Received: by 10.25.29.80 with SMTP id d77mr597688lfd.39.1513139095175; Tue, 12 Dec 2017 20:24:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.170.16 with HTTP; Tue, 12 Dec 2017 20:24:34 -0800 (PST) In-Reply-To: References: Date: Wed, 13 Dec 2017 05:24:34 +0100 X-Gmail-Original-Message-ID: Message-ID: To: =?UTF-8?Q?Micha=C5=82_Brzuchalski?= Cc: Nikita Popov , Stanislav Malyshev , PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Namespace-scoped declares, again From: andreas@dqxtech.net (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 like: > src/Cat.php <-- class Acme\Animal\Cat > src/ns.php <-- that should be then a place for namespace declare or even > 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 consta= nts > 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? 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.