id; } function value(?int $value=null): int { if (is_null($value)) { return $this->value; } return $this->value = $value; } } $test = new Test(42, 255); echo $test->id() . " = " . $test->value() . "\n"; # 42 = 255 get echo $test->id() . " = " . $test->value(44) . "\n"; # 42 = 44 set+get echo $test->id() . " = " . $test->value() . "\n"; # 42 = 44 get