<?php
class Foo {
private $store;
public function __get($name) {
return $this->store[$name] ?? null;
}
public function __set($name, $value) {
$this->store[$name] = $value;
}
}
$foo = new Foo;
$foo->hello = 'hello';
var_dump($foo->hello);
var_dump(isset($foo->hello)); // According to the RFC, this would currently return "true", which is not the case.
var_dump($foo->world);
var_dump(isset($foo->world));
class User
{
public function __construct(private string $first, private string $last) {}
public string $fullName {
get {
return $this->first . " " . $this->last;
}
}
}
$u = new User('Larry', 'Garfield');
var_dump($u->fullName);
var_dump(isset($u->fullName));