$this->convertDotPathToArrayPath($offset)) && ($this->get($offset) !== null) ; } /** * {@inheritdoc} * * Examples of use: * $arrayFinder[4]; * $arrayFinder['a']; */ #[\ReturnTypeWillChange] public function offsetGet($offset) { if (is_int($offset)) { $offset = (string) $offset; } return $this->get($offset); } /** * {@inheritdoc} * * Example of use: $this->arrayFinder['a'] = $value; */ public function offsetSet($offset, $value): void { if (is_int($offset)) { $offset = (string) $offset; } if ($offset === null) { $this->array[] = $value; } else { $this->set($offset, $value); } } /** * {@inheritdoc} * * Example of use: unset($this->arrayFinder['a']); */ public function offsetUnset($offset): void { if (is_int($offset)) { $offset = (string) $offset; } $this->set($offset, null); } /** * Converts paths following format 'dot' structure a.4.9.d.10 * to Symfony format [a][4][9][d][10] * * @param string $dotPath * * @return string */ private function convertDotPathToArrayPath(string $dotPath): string { if ($dotPath === '[]') { return '[0]'; } $expl = explode('.', $dotPath); $in = implode('][', $expl); return str_replace('[]', '[0]', '[' . $in . ']'); } }