Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111905 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 91266 invoked from network); 19 Sep 2020 08:12:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Sep 2020 08:12:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B176A1804D8 for ; Sat, 19 Sep 2020 00:21:03 -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,HTML_MESSAGE, 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-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) (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 ; Sat, 19 Sep 2020 00:21:03 -0700 (PDT) Received: by mail-ed1-f68.google.com with SMTP id c8so8174674edv.5 for ; Sat, 19 Sep 2020 00:21:03 -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; bh=OafM0kGSjvHTEfdiIX39zWxp+xoTDl1Ul5Yhhrq0FtA=; b=A1PUmmcPRIrtsBZZqKYOuUrtbchkWT/XC2eRlI12R8GZyIL5uwIurwIKtBB9mYNCi1 5O2VehgF1OlD+qe62RYXCiy0SvPg6v48G767x31fcaU+F8oEklA3gU3EkenGoZ/yZNC2 t2kv5QGxjPUxLdiuZn01pTuYHlhwRxmd8qgIdF7bIb7rwSNBh+PjXh3Ew3Lmd9QdBd/a /CVYqmnq8rUnLmE9v7QsGzzFNEJbZEP1B8e7cZK/DVIrI9w9hVSmgczGTC+dqnQpzI1U MyLAwPeS+HOnaz05b+4isH3asYX97KncBk+ElTC45il+JDt5dH0q3D7JQETTybgmmDyN 5xsg== 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; bh=OafM0kGSjvHTEfdiIX39zWxp+xoTDl1Ul5Yhhrq0FtA=; b=FZCJOqmM3OhYrcgcoAnW4v5o4gCEIxM2J1+9OYb1romV28g6IpmoAY5Y5LWGOFHMMQ BmzYlrK+iToG3qLVlOIsdW2diHa2xs4rYZd5O/9oles+5PCxTMbSVAyjtTs60worX6ei 5BFiShiiOhoS+OA1/B8SrI4u/RVFlhNMJh8R8xv/5tJiY2qrKWfJufv+8WOmsqi1LnYn WbEpiYxhU38LiyZEBiu7qMhbAkTDXNJMDhxMb+yWERypYpdHj9XYI0zuJByUVmMslFtJ R9zpeArFGB9cAvCyTLhkJe1WaQWfcXEGvTrjzEqu4yO+IdkuixJrv897UPBYgsvb9k+h yZWQ== X-Gm-Message-State: AOAM531KtrIXYtvyH4q7oP5+xxoA0dSMbHfNUA/ScrcTKvzzNt+SOJVI tewE22JV2F8epSOFR2SsjP3jn2V359GUYD6FjfQ= X-Google-Smtp-Source: ABdhPJye4e5uzM6j6I4DBj7T8Puda44XnHAkF1ptRWTg6ZAtD42d3eQJDNgS2yj4XmE7ZBy5UjP8eyWMP/OSq26zTEo= X-Received: by 2002:a50:8524:: with SMTP id 33mr43932553edr.123.1600500061057; Sat, 19 Sep 2020 00:21:01 -0700 (PDT) MIME-Version: 1.0 References: <71C70A3F-4156-4CFE-B55B-CCE306FB9F0E@newclarity.net> In-Reply-To: <71C70A3F-4156-4CFE-B55B-CCE306FB9F0E@newclarity.net> Date: Sat, 19 Sep 2020 09:20:48 +0200 Message-ID: To: Mike Schinkel Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000009a379805afa57530" Subject: Re: [PHP-DEV] Namespace-private class properties From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) --0000000000009a379805afa57530 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 18 Sep 2020, 00:13 Mike Schinkel, wrote: > > > > On Sep 17, 2020, at 8:28 AM, Olle H=C3=A4rstedt > wrote: > > > > (NB: This idea is NOT about namespace visibility for classes, interface= s > or > > traits (already discussed here: > https://wiki.php.net/rfc/namespace-visibility). > > It's about adding a *new* visibility qualifier, call it "internal", to > > make properties > > private inside a namespace. The purpose is to make composition less > > fragile by not > > exposing more than necessary.) > > > > (NB: This feature exists in Swift, described here: > > https://docs.swift.org/swift-book/LanguageGuide/AccessControl.html) > > > > We have public, protected and private. Since PHP has no module system, = we > > have no qualifier to mark a class property as "private for this module"= . > > One solution to this could be to add a new qualifier "internal", to mak= e > > properties public within the current namespace. > > > > Use-cases: > > > > * Split data and behaviour into different files and classes > > * Safely skip getters and setters without risk of properties being abus= ed > > by client code > > +1 > > This might be able to address a use-case I have wanted for a while, which > is to have traits with properties (and methods) that are not accessible > with the class that uses the trait. > > So if a trait is in a different namespace than the using class, the using > class would not be able to access these "internal" properties. > > Or at least I think that could work? > > -Mike > True, the properties/methods of the trait could be made internal, while exposing the trait itself (and at least one method, to make it usable). The question is if PHP tracks the current namespace it's in on each line. It needs to be known at all times for such an access level to work. Olle --0000000000009a379805afa57530--