md(); if ($md !== null) $md->ensureSchema($data, $key); else A::ensure_array($data); return $data; } function __construct($data=null, $key=null) { parent::__construct($this->ensureData($data, $key)); } # Modèle d'implémentation dans une classe dérivée: ## ArrayAccess #function has(KeyType $key): bool { return $this->_has($key); } #function &get(KeyType $key, ?ValueType $default=null): ?ValueType { return $this->_get($key, $default); } #function set(KeyType $key, ?ValueType $value): self { return $this->_set($key, $value); } #function add(?ValueType $value): self { return $this->_set(null, $value); } #function del(KeyType $key): self { return $this->_del($key); } ## Iterator #function key(): KeyType { return $this->_key(); } #function current(): ?ValueType { return $this->_current(); } # Par exemple, pour un array générique, on aurait: ## ArrayAccess #function has($key): bool { return $this->_has($key); } #function &get($key, $default=null) { return $this->_get($key, $default); } #function set($key, $value): self { return $this->_set($key, $value); } #function add($value): self { return $this->_set(null, $value); } #function del($key): self { return $this->_del($key); } ## Iterator #function key() { return $this->_key(); } #function current() { return $this->_current(); } }