*/ private array $attributes = []; /** * @phpstan-return ($key is non-empty-string ? mixed : array) * @return array|mixed|null */ public function attributes(string $key = '') { if ($key === '') { return $this->attributes; } else { return $this->attributes[$key] ?? null; } } /** @param string|array|bool|int|null $value Value, not HTML-encoded */ public function _attributes(string $key, $value = null): void { if ($key == '') { if (is_string($value)) { $value = json_decode($value, true); } if (is_array($value)) { $this->attributes = $value; } } elseif ($value === null) { unset($this->attributes[$key]); } else { $this->attributes[$key] = $value; } } }