Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111906 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 1883 invoked from network); 19 Sep 2020 11:52:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Sep 2020 11:52:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B2B0A1804AA for ; Sat, 19 Sep 2020 04:01:37 -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_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-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) (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 04:01:37 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id z22so11402938ejl.7 for ; Sat, 19 Sep 2020 04:01:37 -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=gHyvFvHJuJFZLaJXoEYQJuguqvMDqLI0cNp63x571uQ=; b=VTUnTJOwWCx/v3W2Cn6urFk05gcE5zNSDggGvONNJ+8MAxi3t/Dbdj/zMvwlGSMzVV 47CaLeSlyByX/QMFwu8A+zzPnDjkw+R51nh9Vpi45kuHXr3lTsbvwCWOlLplNhGkKAcg 9p4IkcYCJvLjjGkU6JDvtelUn5k5YIjQ4ke2ENnjUvFqlBAWq1sgXHlbYfOgGRBtYY0r q1mHxsVkOec67itLTGx6DbQmatfhaeMOtTmylshqcYgwmGrIySeBsOuy3ccQ6HWX+ADV mmTzqXFQ29CsOqHPP2WNSMWyTN3mjkFNk4YIj72uizSfwf4uID0xx63hRYx/GNyPiKLq GcCg== 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=gHyvFvHJuJFZLaJXoEYQJuguqvMDqLI0cNp63x571uQ=; b=cBCUw1aA7+ymEUErI9o5mBJ21EEdC91TCI8gI6JedlI5+DskFRy3vBO0l0DSTt77iZ jxhq5FB+/cLfEpTSRKsUr922ST1ZUrKWdkzpTE8BDDwPf4w+YHxEe9mFkjHzcBELN6uc +pzPM0Eey63qA9+hcZOvhOeTCDOYPq9WMYqn5x+kQsgP+jP9B3eNTuuhep2Rb+cL0Vzq vfspLe2QuBA4qYJa2+s63RHzVwJK3JiJheOdwwUainObIBus9nzcaxEwczSlAcminQvH sHiRKSIRaRcKb9bJva8Rw3Wl6FIwGL9voimQE7rV0AMww2Bov02HZkAEcj6oAu3IHM2b cpzQ== X-Gm-Message-State: AOAM531b4Sc2WMgrAwgnLbT7M5Z/4anUuKuTLuKeHIsAsSKwTFvWRaVs oCcHRFKt/1n/zXewcj7AdjCUTt/3jQNXV0YmLO7DrNK1 X-Google-Smtp-Source: ABdhPJzlfOw9zSMCE1yGp2cVXPbsP8KhUebBhXXtGPuaJbK3s36psBHTIu3E943WnX74DfVpTQxI1dIMtoFT+K1vjZo= X-Received: by 2002:a17:906:3955:: with SMTP id g21mr40848135eje.69.1600513293551; Sat, 19 Sep 2020 04:01:33 -0700 (PDT) MIME-Version: 1.0 References: <71C70A3F-4156-4CFE-B55B-CCE306FB9F0E@newclarity.net> In-Reply-To: Date: Sat, 19 Sep 2020 13:01:19 +0200 Message-ID: To: Mike Schinkel Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000520b6c05afa88a29" Subject: Re: [PHP-DEV] Namespace-private class properties From: olleharstedt@gmail.com (=?UTF-8?Q?Olle_H=C3=A4rstedt?=) --000000000000520b6c05afa88a29 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, 19 Sep 2020, 09:20 Olle H=C3=A4rstedt, wro= te: > > 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, >> interfaces 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 ma= ke >> > 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 >> abused >> > by client code >> >> +1 >> >> This might be able to address a use-case I have wanted for a while, whic= h >> 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 usin= g >> 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 > Just discovered that this feature already exists in Psalm, @psalm-internal. They are streets ahead. :) Olle > --000000000000520b6c05afa88a29--