-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Labels
Milestone
Description
Description
Since PHP 8.4 property hooks are possible which could optionally replace the setter and getter of the Entities.
In the __get() and __set() methods there is at the moment no checks for virtual properties (only if configured with prefix _get as method).
This could be optionally added, so both can be used. I think it should be possible backward compatible.
virtual property getter $formatted_title
protected function _getFormattedTitle(): string
{
return $this->booking_date->i18nFormat('short') . ', ' . Number::formatOutput($this->amount) . ' EUR';
}
property hook
public string $formatted_title {
get {
return $this->booking_date->i18nFormat('short') . ', ' . Number::formatOutput($this->amount) . ' EUR';
}
}
and setter $title
protected function _setTitle($value)
{
return str_replace(["'", '"', '[', ']', '/', '\\', '{', '}'], '', $value);
}
property hook:
public string $title {
set {
$this->title = str_replace(["'", '"', '[', ']', '/', '\\', '{', '}'], '', $value);
}
}
CakePHP Version
5.1.5