- Output for 8.4.10
- 42
Fatal error: Uncaught LogicException: nope in /in/2JagR:6
Stack trace:
#0 /in/2JagR(14): Foo->$bar::set(43)
#1 {main}
thrown in /in/2JagR on line 6
Process exited with code 255.
<?php
class Foo {
public int $bar {
get => $this->bar;
set => empty($this->bar) ? $this->bar = $value : throw new LogicException("nope");
}
}
$foo = new Foo();
$foo->bar = 42;
echo $foo->bar . "\n";
$foo->bar += 1;