1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
--TEST--
GH-15644: Asymmetric visibility doesn't work for set hook
--FILE--
<?php
class C {
public private(set) string $prop1 {
set => $value;
}
public private(set) string $prop2 {
get => $this->prop2;
}
}
$c = new C();
try {
$c->prop1 = 'hello world';
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
$c->prop2 = 'hello world';
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Cannot modify private(set) property C::$prop1 from global scope
Cannot modify private(set) property C::$prop2 from global scope
|