> On Aug 26, 2021, at 9:47 AM, Olle Härstedt <olleharst...@gmail.com> 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? 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? And if not, what about traits makes them not-applicable here? Maybe we could also address that? -Mike -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php