data = $enc ?? []; } public function getIterator(): \Traversable { return new \ArrayIterator($this->data); } public function count(): int { return count($this->data); } public function offsetExists($offset): bool { return isset($this->data[$offset]); } #[\ReturnTypeWillChange] public function offsetGet($offset) { return $this->data[$offset]; } public function offsetSet($offset, $value): void { if (is_null($offset)) { $this->data[] = $value; } else { $this->data[$offset] = $value; } } public function offsetUnset($offset): void { unset($this->data[$offset]); } public function __set(string $name, $value): void { if ($this->data) { $this->default()->__set($name, $value); } else { $this->$name = $value; } } public function __get(string $name) { if ($this->data) { return $this->default()->__get($name); } else { return $this->$name; } } public function __isset(string $name): bool { if ($this->data) { return $this->default()->__isset($name); } else { return isset($this->$name); } } public function __unset(string $name): void { if ($this->data) { $this->default()->__unset($name); } else { unset($this->$name); } } protected function default(): self { foreach ($this->data as $m) { if ($m->preferred) { return $m; } } return $this->data[array_keys($this->data)[0]]; } }