List of supported field handles. */ public static $fieldHandles = [ /* HANDLES */ ]; /* PROPERTIES */ /** * @var array Additional custom field values we don’t know about yet. */ private array $_customFieldValues = []; /** * @inheritdoc */ public function __call($name, $params) { if ($this->hasMethods && isset(self::$fieldHandles[$name]) && count($params) === 1) { $this->$name = $params[0]; return $this->owner; } return parent::__call($name, $params); } /** * @inheritdoc */ public function hasMethod($name): bool { if ($this->hasMethods && isset(self::$fieldHandles[$name])) { return true; } return parent::hasMethod($name); } /** * @inheritdoc */ public function __isset($name): bool { if (isset(self::$fieldHandles[$name])) { return true; } return parent::__isset($name); } /** * @inheritdoc */ public function __get($name) { if (isset(self::$fieldHandles[$name])) { return $this->_customFieldValues[$name] ?? null; } return parent::__get($name); } /** * @inheritdoc */ public function __set($name, $value) { if (isset(self::$fieldHandles[$name])) { $this->_customFieldValues[$name] = $value; return; } parent::__set($name, $value); } /** * @inheritdoc */ public function canGetProperty($name, $checkVars = true): bool { if ($checkVars && isset(self::$fieldHandles[$name])) { return true; } return parent::canGetProperty($name, $checkVars); } /** * @inheritdoc */ public function canSetProperty($name, $checkVars = true): bool { if (!$this->canSetProperties) { return false; } if ($checkVars && isset(self::$fieldHandles[$name])) { return true; } return parent::canSetProperty($name, $checkVars); } }