On Wed, May 29, 2024, at 7:51 PM, Tim Düsterhus wrote:
> Hi
>
> On 5/29/24 21:15, Larry Garfield wrote:
>> * We've brought back the abbreviated form, as public-read, something else 
>> set is the most common use case.
>
> The most common use case is that 'get' and 'set' are symmetric. 

OK, fair, I meant in the most common case where you're using aviz at all, get 
is probably public.

That said, with both hooks and aviz, I can see data objects, for instance, 
becoming commonly public-get, private-set.  It's already common to have them be 
public readonly, so this is just an extension of that.

> Any 
> divergence from that should stand out and I think that the hamming 
> distance between
>
>      protected string $foo;
>
> and
>
>      protected(set) string $foo;
>
> is too small.

I can only respectfully disagree here.  I think it's reasonably self-evident, 
made moreso by the (), which as Andreas noted looks weird when you're not used 
to it (but we should get used to fairly quickly).  And the benefit of not 
having to type "public" on every property outweighs any initial confusion, much 
the same as readonly classes just reduces boilerplate.

> One note regarding the text. You already confirmed to me in private that:
>
>      class Foo {
>          private $dontTouchMe;
>      }
>
>      $backdoor = function ($key, $value) { $this->{$key} = $value; };
>
>      $f = new Foo();
>      $backdoor->call($f, 'dontTouchMe', 'butIDid');
>      var_dump($f);
>
> would work as expected with aviz. It would make sense to explicitly 
> spell that out, just like it's explicitly spelled out that 
> `ReflectionProperty::setValue()` works.

Added a note to that effect in the Reflection section as well.  Thanks.

--Larry Garfield

Reply via email to