Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115863 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41430 invoked from network); 26 Aug 2021 17:55:34 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2021 17:55:34 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B38371804B3 for ; Thu, 26 Aug 2021 11:30:05 -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=-0.7 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS 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-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 11:30:05 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id q14so6535677wrp.3 for ; Thu, 26 Aug 2021 11:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=5KbLbnJycD1jvUoBDrZs1kq9tCcIupa8R2gQBedpkco=; b=a63sDXEc6UxOi3DxFIoH5cB4AgtJQwy4qXaT1/DaGj+soYyRCb8QJibFmiqan3aVoU bZ+Pz4siu6qh2eu+VWFOVkHDoyP6sIE439mfL+/Of244awfeUU6Nv+bo4dKOh0Imdz3X PHeAt8xnTE3NMmIXa8cHHg8FCQPUjrUUVLndqlko5dLvq3O/01Kb17wV4e/6TpHNTaHH MT8dPp57tVRZQnTXheGRdTdXoJ3/gGz7nI+475QYY4gwmbUmHXGDAmPUmKqcr7/ny3up P6pxbISnvjY6O0PYhF4BweyURCRuTqFrvcE8d+lX1R5XiG3tTdXfm8LTHTlvqr89XH8S c2Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=5KbLbnJycD1jvUoBDrZs1kq9tCcIupa8R2gQBedpkco=; b=QtCEsD8csTcRqFLYvmvZiWBPwo1OguUvzz8N4w5xjPFLvRYE09hEnOFbzZs9l0dJT7 o6wwxIKMgEMpXpXro79/6PXGMoJNRkHB3ru2FV6Ek+fSpbvR/AMWzKvjHmrxABlpZ6Sm m5LvlZiyidAUc8MT3e4dsQ/vXgZY9dA58wVKMn6jYoYKUOnHcx4Zd0NoP+rYHFSbyLOQ ijnr0IfDL43yCSrfAHtNP17STqqqDT/aNwbaT2hhHiFE2r8tWyWdGBszLuD0MjahlsCg TiCrUuCAdCkNIgu85YcqwyBKUXiGjvmb5asJkgPqS76a34lMcgoF7o65hjJqciHu0YJX J8Ew== X-Gm-Message-State: AOAM533CAQtvmUBjQ72EMtqZgXs1YVG+aHhVFmZkI735LyyevOpopVB7 TLI6ijwD7z0MSbKpIankNY24I2CIoqc= X-Google-Smtp-Source: ABdhPJyX+A3wgP+gqWFG1PhhCUcLbXneFKVvuPPcfUw5DZCMaPfJMTh6S/A8b3CcVTshDdcmvDgH3w== X-Received: by 2002:adf:9063:: with SMTP id h90mr5798336wrh.121.1630002604113; Thu, 26 Aug 2021 11:30:04 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id s7sm3903504wra.75.2021.08.26.11.30.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 11:30:03 -0700 (PDT) To: internals@lists.php.net References: Message-ID: Date: Thu, 26 Aug 2021 19:30:02 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] Alternatives for encapsulation when using composition instead of inheritance From: rowan.collins@gmail.com (Rowan Tommins) On 26/08/2021 14:47, Olle Härstedt wrote: > Don't know if this already exists, but maybe we could consider > brainstorming or gather alternatives for different types of > encapsulation when using composition? Although not quite equivalent to your suggestions, these threads on making delegation to an encapsulated object might be interesting to you: *  https://externals.io/message/103353 * https://github.com/php/php-src/pull/5168 If we had something like that, then perhaps there could be a "delegatable" visibility, which was the equivalent for "protected", but when delegating rather than inheriting, e.g. class Foo {     private int $a = 1;     delegatable int $b = 2; } class Bar {     private delegate Foo $foo;     public function __construct(Foo $foo) {         $this->foo = $foo;         echo $this->a; // Error: can't access private property of a different class         echo $this->b; // allowed: access is to a "delegatable" property, in a "delegated" context     } } -- Rowan Tommins [IMSoP]