<?php new class { private array $data = ['foo' => true, 'bar' => false,]; function __construct() { // $this->foo ||= true; $this->foo || ($this->foo = true); assert($this->data['foo'] === true); // $this->bar ||= false; $this->bar || ($this->bar = false); assert($this->data['bar'] === false); } function __get(string $name): bool { echo "Getter called for {$name}\n"; return $this->data[$name]; } function __set(string $name, bool $value): void { echo "Setter called for {$name}\n"; $this->data[$name] = $value; } };
You have javascript disabled. You will not be able to edit any code.