1--TEST--
2Asymmetric visibility unset protected(set)
3--FILE--
4<?php
5
6class Foo {
7    public protected(set) string $bar;
8
9    public private(set) string $secret;
10
11    public function setBar($bar) {
12        $this->bar = $bar;
13    }
14
15    public function setSecret($s) {
16        $this->secret = $s;
17    }
18
19    public function unsetBarPrivate() {
20        unset($this->bar);
21    }
22}
23
24class FooChild extends Foo {
25    public function unsetBarProtected() {
26        unset($this->bar);
27    }
28
29    public function unsetSecret() {
30        unset($this->secret);
31    }
32}
33
34$foo = new FooChild();
35
36$foo->setBar('bar');
37try {
38    unset($foo->bar);
39} catch (Error $e) {
40    echo $e->getMessage(), "\n";
41}
42var_dump($foo->bar ?? 'unset');
43
44$foo->setBar('bar');
45$foo->unsetBarPrivate();
46var_dump($foo->bar ?? 'unset');
47
48$foo->setBar('bar');
49$foo->unsetBarProtected();
50var_dump($foo->bar ?? 'unset');
51
52$foo->setSecret('beep');
53try {
54    $foo->unsetSecret();
55} catch (Error $e) {
56    echo $e->getMessage(), "\n";
57}
58var_dump($foo->secret ?? 'unset');
59
60?>
61--EXPECT--
62Cannot unset protected(set) property Foo::$bar from global scope
63string(3) "bar"
64string(5) "unset"
65string(5) "unset"
66Cannot unset private(set) property Foo::$secret from scope FooChild
67string(4) "beep"
68