Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111922 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75441 invoked from network); 22 Sep 2020 16:16:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Sep 2020 16:16:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6FCCA180511 for ; Tue, 22 Sep 2020 08:26:31 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (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 08:26:30 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id z22so23448632ejl.7 for ; Tue, 22 Sep 2020 08:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vQWeYqWf+VjKfKFA10Qbmb2Qu6A1pXLDF9bsQ42HGEc=; b=uEAB34SwJRJUhWfHUTK5KNpxq4Xm7DRcmcRVuIlZFfZwrGfcL5DznETuReherQSLrU kqqb9swxk3qgQGx53UM9R6ByhZIQEBL/Etq6xax7Yvyp5mi2TrRmArqoYUiV+1D8BtWR iHkqfrDUBgaAgOyLjElYwWr5jRiemtTl9cchcluiN4Yumi/eCBlGnT+P4yoNfpSVZ5+C Oseb0D8bqLrWQzr8AtBgU1FqU0QLAqIq6tpMWEJzU/mKtQ1M2sj1BIws44jO6CofbN18 Wd/hfiKdtzyZoXOT4luLPo0YehnC9h1xS4NHEUOSDfntgFHhigDHq9K5L3gwzV+NXqwc MT+A== 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=vQWeYqWf+VjKfKFA10Qbmb2Qu6A1pXLDF9bsQ42HGEc=; b=SKHZmxglzkdJcAyRBee7geuE9IDRIVoErPQ4mUgDqu4JPeNGWcngFlKOvL+uRuw3S8 Rxv3/PpJjse/prLa6mvnM7r2I19iCcle8o75uxq/ZZVQXc8Hi2+sxfuKSuuoC+i/3cCR OUepXdqtsROACeNNYzEvCNnHJ0AaQEpT1J925YET8wV0MPJZfHtRlbcHYvXZWQk8YL5G 5C8zCDEBbXBZS/Ha3Uw7zmXWtr/ObnCAQis8K9C80QDeZT3txedv95mM5cj+bNEZ6lGb ME9nWekcgSdp2HSv+cDO6VIie7+wvLfpD7WvKWxLcvQhkaJdV/R6kHVfPniN5yaLynzc L+yg== X-Gm-Message-State: AOAM533iCwbnWi8h5TAJ6PnyHKBPyFXc5eAjCCNm9otpeIiNWXjnKRBP s1LTpfxxffJqNm1k0DFdm4ByomgPJlbN4IHFSwM= X-Google-Smtp-Source: ABdhPJyEQyW44oJZSnEGBX2ecV58l1jdWZejY1q/K5dtoQSpbjqk+REgGtN2qwTiRJIxuT9LsTf/6H0Hgy3z9UjzOIM= X-Received: by 2002:a17:906:914b:: with SMTP id y11mr5591412ejw.145.1600788386573; Tue, 22 Sep 2020 08:26:26 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a54:3ac6:0:0:0:0:0 with HTTP; Tue, 22 Sep 2020 08:26:25 -0700 (PDT) In-Reply-To: References: <994c6693-a405-ce0f-399c-1518a7eeb321@gmail.com> <4dc36ca7-3af5-fb53-521a-e7a85a5b4006@gmail.com> Date: Tue, 22 Sep 2020 15:26:25 +0000 Message-ID: To: "guilhermeblanco@gmail.com" 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: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) 2020-09-22 14:51 GMT, guilhermeblanco@gmail.com = : > This should answer your question: > https://github.com/php/php-src/pull/947#issuecomment-224912697 > Yes, indeed. "The reason comes due to how namespaces are implemented in the language, where they only exist at compile time." Pity. > 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 >> >> the >> >> protected keyword in PHP, and honestly I prefer PHP's interpretation >> >> of >> >> 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 concep= t >> > for this, we potentially have a third dimension: is it private to _thi= s >> > 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 >> > this >> > 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/class= es-and-structs/access-modifiers >> > [4] >> > https://docs.elementscompiler.com/Oxygene/Members/VisibilityLevels/str= ucts/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 >> > > > -- > Guilherme Blanco > SVP Technology at Statflo Inc. > Mobile: +1 647 232 5599 >