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