Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115867 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50740 invoked from network); 26 Aug 2021 19:27:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2021 19:27:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5755B1804AC for ; Thu, 26 Aug 2021 13:01:35 -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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 ; Thu, 26 Aug 2021 13:01:34 -0700 (PDT) Received: by mail-qk1-f172.google.com with SMTP id b64so4914534qkg.0 for ; Thu, 26 Aug 2021 13:01:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oLsrcfniHbcZJy9UPqvX8UPLERE0BQBwD5Tder1JLZ4=; b=vNWDtTwnrwtz1SKkcRrb2iMKxqIZuUdJNGIKpCF2rYug5QAE4aW1Mib3dkerZNk05r wIi/OfN9PXYL7/Av+74tnZt4Ow2TLTiEsNntGBrI2LrDsDNwZcznZ8fjhy+7yWCAjFwB nFKUn5/rJZHfQm1sDGeQgt0qSwHD8w35vlu3yAIhdTo9kXz6a57KKGCxUq2s2Az8kfsx ay8S/2rrIO9XXzh/9pzunG5/rQ5x6I8Bi5pZJB6CmVjg8H1qQYj9/oW6q+ouf9QTrFWM RtzhdFfzCI4n43tlLpWJOg/Fw3STnLbK8nESsrt3MVRl8a9Ckhrr+CRnsKdI3+J4VtE8 x4jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=oLsrcfniHbcZJy9UPqvX8UPLERE0BQBwD5Tder1JLZ4=; b=oQCpaUxVpVJC1U0C9XRoppqu5HUOSq5aUa7/0W6jMHkI0i8aDeQSLUtKKw3regS+Xp YRbxRHVyuSayUUot4cGiMUcRo3e9OBxMJVIrr0VCucVx7g1vB1r8HMMEsxDigzZivkjJ f1W4Bg5l9robtpO62oLlRhyaU21iLOFI4axOcaW95p4GEQlPWVkVJDx2OWB9jYg0e80d rEEAShqpQp7gDwd423jD9IxOVQoeC6HYpPpbkq5g14ucNxCZZiQfMAxV6ar1zy/wrY/X Qtxjye8qSUPahxXuPSIduFVdNZAD66oqrqTVCMAG1696ALuJ3NgZAh6CspCaNZ+WVdVc albA== X-Gm-Message-State: AOAM530mnuZU86O3dUkxKq1oxDcpcGR08kRNGVCkUyCwUHsqO5udsFTx 7ggZv6fGL67LIj/vlyMEf9E7PYnjoioyzRCO X-Google-Smtp-Source: ABdhPJyfQgbhCbJPKAfUVN3o30wpXLrTvgCD456FzGJ3k+GhxHoISDLPRo8Sjt2oxvP+oumeTrPtMQ== X-Received: by 2002:a05:620a:1671:: with SMTP id d17mr5615120qko.191.1630008094249; Thu, 26 Aug 2021 13:01:34 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id x29sm2368908qtv.74.2021.08.26.13.01.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Aug 2021 13:01:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: Date: Thu, 26 Aug 2021 16:01:33 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: =?utf-8?Q?Olle_H=C3=A4rstedt?= X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] Alternatives for encapsulation when using composition instead of inheritance From: mike@newclarity.net (Mike Schinkel) > On Aug 26, 2021, at 9:47 AM, Olle H=C3=A4rstedt = wrote: >=20 > Don't know if this already exists, but maybe we could consider > brainstorming or gather alternatives for different types of > encapsulation when using composition? Currently, encapsulation like > private and protected is only possible when using inheritance - when > using composition, that is, class A is using (aggregating) class B, > your only alternative is public, so full visibility (or > getters/setters, which also is full visibility, since you can't limit > who's using those methods). When you say "composition" I think of traits, but it does not appear = that is what you mean? I have often wanted to be able to create a trait-private property so = that I could write a `trait` and be confident that the classes that use = it don't start using its internal properties and tie my hands in terms = of being able to upgrade the trait to better internal approaches as I = evolve the trait. Would trait-private address any part of what you need? Or would other = trait-specific visibility address what you need?=20 And if not, what about traits makes them not-applicable here? Maybe we = could also address that? -Mike=