On Wed, Nov 30, 2022, at 12:10 PM, Claude Pache wrote: > Hi, > > What is the behaviour of the following code? > > ```php > class Foo { > public private(set) array $bar = [ ]; > } > > $foo = new Foo; > > $foo->bar['x'] = 'y'; // error? > > var_dump(isset($foo->bar['x'])); // true?, false? > ``` > > I think that modification of an array should require write access? > (That should be clarified in the RFC.)
Correct, that would not be allowed. Array writes are always indirect modification, because it's two steps to get to it. That will error out in this case, as one would expect from `private(set)`. --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php