1--TEST--
2Asymmetric visibility __set
3--FILE--
4<?php
5
6class Foo {
7    public private(set) string $bar;
8
9    public function setBar($bar) {
10        $this->bar = $bar;
11    }
12
13    public function unsetBar() {
14        unset($this->bar);
15    }
16
17    public function __set(string $name, mixed $value) {
18        echo __CLASS__, '::', __METHOD__, "\n";
19    }
20}
21
22$foo = new Foo();
23try {
24    $foo->bar = 'baz';
25} catch (Error $e) {
26    echo $e->getMessage(), "\n";
27}
28
29$foo->setBar('baz');
30try {
31    $foo->bar = 'baz';
32} catch (Error $e) {
33    echo $e->getMessage(), "\n";
34}
35
36$foo->unsetBar();
37$foo->bar = 'baz';
38
39?>
40--EXPECT--
41Cannot modify private(set) property Foo::$bar from global scope
42Cannot modify private(set) property Foo::$bar from global scope
43Foo::Foo::__set
44