Open
Description
As PHP 8.4 comes with property hooks we could remove virtual properties, as they would be completely modelled
by a custom property with getter hook.
This:
/** ...
* @property-read int $age {virtual}
*/
final class Author extends Entity
{
protected function getterAge(): int
{
if ($this->born === null) {
return 0;
}
return ((int) date('Y')) - ((int) $this->born->format('Y'));
}
}
Would become
/** ...
*/
final class Author extends Entity
{
public int $age {
get {
if ($this->born === null) {
return 0;
}
return ((int) date('Y')) - ((int) $this->born->format('Y'));
}
}
}
Please note, that this would not mean removing custom getters/setters support, as they're still needed for non-virtual properties.