Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111921 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 71735 invoked from network); 22 Sep 2020 15:42:17 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Sep 2020 15:42:17 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7FB10180541 for ; Tue, 22 Sep 2020 07:52:04 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 22 Sep 2020 07:52:01 -0700 (PDT) Received: by mail-ot1-f44.google.com with SMTP id o6so15879244ota.2 for ; Tue, 22 Sep 2020 07:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+HhiO3DtxU52+m3WXqvx25SqKPOosioSUXo4oot1xDU=; b=qwNGzqvXmaKi1a1U6qomamBro1ssmG2l54/FuBsbsnqVQQSttk+jttFd1cSnipy4DM B6AYs1AufbHf9XGtCtyNvUK4EzAB1ZENpl5h5fvH/ponoSU7RnTLf/Se9RHa81UVYuNH Q2d6/35OAyZGj4ApS4+l8HFLUuWvJs1QtDR3lz1Wp+vq/usmLnZZwqrVf+0msSXqZESU yhJAtvEjkKT/+Ct8wl0mMktUEBldcW7a5TtHzkQytzmKw2rnXi/0jp8iqECfy15tT8z8 hbSqOu0gjZxY40Gt8pW57Vh6+NAWGlIU9Fdv4QVI9t+rCpcdsWplhVdozdGVEncEXI7X KPQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=+HhiO3DtxU52+m3WXqvx25SqKPOosioSUXo4oot1xDU=; b=irHIB0x/nsW+a8f2qpqmL4rJBPjyJqnmtyoTAYg/rS9EQuuikU1JegGnl7MfGgLoN5 aiqXV7gM/8DJ8Deye9tZrGpRNmYEqbHcALUoptlGic9jbHbeRhDPCDlX1Yd2QHgtd8I1 yt+5p8Hvts7NQyV+M13Yj/pzeNH62BzchifYxzRIA9QMlbz9epq/+wDJUeGOsNSQd2F2 NitBQnJO6XJkm2HujYO9MxIvK5u9w6LeFH8Pkysoo/yG9G6RI+jJ/Hfzl6zsOZxO2SVT 7mjHsy5PSyrdu2Ii3V91DmbkDNGHGyX1a8PoAAqpXRBuDt1sMt/PYe8UrJjHEMKBuPTJ Q8eg== X-Gm-Message-State: AOAM532JpybMgINRwHVFnU40qFtU6Y8es5r1EhcSLMBpD/afz1B188+x AkPc8KS3RzpiUprvAe8dx7uCKnfZy2OTOurgago= X-Google-Smtp-Source: ABdhPJzW1R8GjhazX+nI92yDSftZtE/dmC38jgelbjvqoGzRK7/7fbXC5AWrTd+K9BP8jrHTrHv29xi/WtAYGKL1IOI= X-Received: by 2002:a05:6830:154a:: with SMTP id l10mr2936508otp.56.1600786317883; Tue, 22 Sep 2020 07:51:57 -0700 (PDT) MIME-Version: 1.0 References: <994c6693-a405-ce0f-399c-1518a7eeb321@gmail.com> <4dc36ca7-3af5-fb53-521a-e7a85a5b4006@gmail.com> In-Reply-To: Date: Tue, 22 Sep 2020 10:51:46 -0400 Message-ID: To: =?UTF-8?Q?Olle_H=C3=A4rstedt?= Cc: Rowan Tommins , PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Namespace-private class properties From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") This should answer your question: https://github.com/php/php-src/pull/947#issuecomment-224912697 On Tue, Sep 22, 2020 at 7:38 AM Olle H=C3=A4rstedt = wrote: > > 2020-09-21 21:50 GMT, Rowan Tommins : > > On 21/09/2020 17:13, Michael Morris wrote: > >> Next thing to consider - we have the problem of having already used th= e > >> protected keyword in PHP, and honestly I prefer PHP's interpretation o= f > >> the > >> word. > > > > > > I think it's actually Java that's the outlier here: PHP's meaning of > > "protected" corresponds directly to C++, and to name a few I came upon > > in a quick search it's also used that way by Kotlin [1], Scala [2], C# > > [3] and Oxygene [4] - all of which use other ways to signal package > > visibility: > > > > - Kotlin has a fourth visibility, "internal", meaning "public within > > this module" > > - Scala has an interesting syntax where you can modify the visibility > > with the name of a package, as in "private[SomePackage]" > > - C# adds *three* extra visibility modes: "internal", "internal > > protected", and "private protected" > > - Oxygene (a language I know next to nothing about) apparently has no > > fewer than TEN modes, including both "assembly or protected" and > > "assembly and protected" > > > > > > All of which I think shows two things: firstly, that there are lots of > > different ways to express this concept; and secondly, that there are a > > lot of subtle combinations that might be useful. > > > > The C# list is particularly confusing, presumably because it's evolved > > without a coherent plan. If I'm understanding correctly, C#'s "private > > protected" corresponds to Oxygene's much clearer "assembly and > > protected", while "protected internal" corresponds to "assembly or > > protected". Considering those combinations up front might be sensible, > > even if they're not implemented at once. > > > > > > If we're considering using namespaces rather than a new package concept > > for this, we potentially have a third dimension: is it private to _this > > exact namespace_, or any "child" namespace starting with the same > > prefix? Maybe something like Scala's modifier syntax might be more > > useful, for instance: > > > > namespace Acme\Frobulator\Helpers\File; > > class FileWidget { > > private[namespace] $foo; // accessible specifically in the > > "Acme\Frobulator\Helpers\File" namespace > > private[Acme\Frobulator\Helpers\File\*] $bar; // accessible in thi= s > > namespace, and all sub-namespaces > > private[Acme\Frobulator\*] $baz; // accessible in "Acme\Frobulator= " > > and all its sub-namespaces > > } > > > > > > [1] https://kotlinlang.org/docs/reference/visibility-modifiers.html > > [2] https://www.tutorialspoint.com/scala/scala_access_modifiers.htm > > [3] > > https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classe= s-and-structs/access-modifiers > > [4] > > https://docs.elementscompiler.com/Oxygene/Members/VisibilityLevels/stru= cts/access-modifiers > > > > > > Regards, > > > > -- > > Rowan Tommins (n=C3=A9 Collins) > > [IMSoP] > > > > -- > > PHP Internals - PHP Runtime Development Mailing List > > To unsubscribe, visit: https://www.php.net/unsub.php > > > > > > All good ideas, but I still don't know if PHP is aware of current > namespace at all time? Anyone has this knowledge? It's a precondition > to check namespace access. > > Olle > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > --=20 Guilherme Blanco SVP Technology at Statflo Inc. Mobile: +1 647 232 5599