<?php class Foo { public function __construct(private Bar $bar, private string $_value = 'foo') {} public string $value { get => $this->_value; set { $this->bar->doSomething($this); $this->_value = $value; } } } class Bar { public function doSomething(Foo $foo): void { $oldValue = $foo->value; } } $foo = new Foo(new Bar()); $foo->value = 'bar';
You have javascript disabled. You will not be able to edit any code.