Re: Alternatives for encapsulation when using composition instead of inheritance
| From: | Rowan Tommins | Date: | Thu, 26 Aug 2021 21:53:30 +0000 |
| Subject: | Re: Alternatives for encapsulation when using composition instead of inheritance | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115870@lists.php.net to get a copy of this message | ||
On 26 August 2021 21:20:35 BST, "Olle Härstedt" <olleharstedt@gmail.com> wrote:
>The Foo class has to decide who to give access to, otherwise it's the
>same as public access.
It does decide who has access: any class that declares it as "delegated". In exactly the
same way, "protected" gives access to any class that declares it as a "parent",
and namespace visibility would give access to any class that declares itself in the same namespace.
None of those actually limit access to a named list of classes, but all of them document an intended
use, and catch mistakes where that intent isn't followed.
Regards,
--
Rowan Tommins
[IMSoP]