nce 1.4.0 */ public function append($path, $value) { $result = null; /* * Explode the registry path into an array and remove empty * nodes that occur as a result of a double dot. ex: joomla..test * Finally, re-key the array so they are sequential. */ $nodes = array_values(array_filter(explode('.', $path), 'strlen')); if ($nodes) { // Initialize the current node to be the registry root. $node = $this->data; // Traverse the registry to find the correct node for the result. // TODO Create a new private method from part of code below, as it is almost equal to 'set' method for ($i = 0, $n = \count($nodes) - 1; $i <= $n; $i++) { if (\is_object($node)) { if (!isset($node->{$nodes[$i]}) && ($i !== $n)) { $node->{$nodes[$i]} = new \stdClass; } // Pass the child as pointer in case it is an array $node = &$node->{$nodes[$i]}; } elseif (\is_array($node)) { if (($i !== $n) && !isset($node[$nodes[$i]])) { $node[$nodes[$i]] = new \stdClass; } // Pass the child as pointer in case it is an array $node = &$node[$nodes[$i]]; } } if (!\is_array($node)) { // Convert the node to array to make append possible $node = get_object_vars($node); } $node[] = $value; $result = $value; } return $result; } /** * Delete a registry value * * @param string $path Registry Path (e.g. joomla.content.showauthor) * * @return mixed The value of the removed node or null if not set * * @since 1.6.0 */ public function remove($path) { // Cheap optimisation to direct remove the node if there is no separator if (!strpos($path, $this->separator)) { $result = (isset($this->data->$path) && $this->data->$path !== '') ? $this->data->$path : null; unset($this->data->$path); return $result; } /* * Explode the registry path into an array and remove empty * nodes that occur as a result of a double separator. ex: joomla..test * Finally, re-key the array so they are sequential. */ $nodes = array_values(array_filter(explode($this->separator, $path), 'strlen')); if (!$nodes) { return; } // Initialize the current node to be the registry root. $node = $this->data; $parent = null; // Traverse the registry to find the correct node for the result. for ($i = 0, $n = \count($nodes) - 1; $i < $n; $i++) { if (\is_object($node)) { if (!isset($node->{$nodes[$i]}) && ($i !== $n)) { continue; } $parent = &$node; $node = $node->{$nodes[$i]}; continue; } if (\is_array($node)) { if (($i !== $n) && !isset($node[$nodes[$i]])) { continue; } $parent = &$node; $node = $node[$nodes[$i]]; continue; } } // Get the old value if exists so we can return it switch (true) { case \is_object($node): $result = isset($node->{$nodes[$i]}) ? $node->{$nodes[$i]} : null; unset($parent->{$nodes[$i]}); break; case \is_array($node): $result = isset($node[$nodes[$i]]) ? $node[$nodes[$i]] : null; unset($parent[$nodes[$i]]); break; default: $result = null; break; } return $result; } /** * Transforms a namespace to an array * * @return array An associative array holding the namespace data * * @since 1.0 */ public function toArray() { return (array) $this->asArray($this->data); } /** * Transforms a namespace to an object * * @return object An an object holding the namespace data * * @since 1.0 */ public function toObject() { return $this->data; } /** * Get a namespace in a given string format * * @param string $format Format to return the string in * @param mixed $options Parameters used by the formatter, see formatters for more info * * @return string Namespace in string format * * @since 1.0 */ public function toString($format = 'JSON', $options = array()) { // Return a namespace in a given format $handler = AbstractRegistryFormat::getInstance($format, $options); return $handler->objectToString($this->data, $options); } /** * Method to recursively bind data to a parent object. * * @param object $parent The parent object on which to attach the data values. * @param mixed $data An array or object of data to bind to the parent object. * @param boolean $recursive True to support recursive bindData. * @param boolean $allowNull True to allow null values. * * @return void * * @since 1.0 */ protected function bindData($parent, $data, $recursive = true, $allowNull = true) { // The data object is now initialized $this->initialized = true; // Ensure the input data is an array. $data = \is_object($data) ? get_object_vars($data) : (array) $data; foreach ($data as $k => $v) { if (!$allowNull && !(($v !== null) && ($v !== ''))) { continue; } if ($recursive && ((\is_array($v) && ArrayHelper::isAssociative($v)) || \is_object($v))) { if (!isset($parent->$k)) { $parent->$k = new \stdClass; } $this->bindData($parent->$k, $v); continue; } $parent->$k = $v; } } /** * Method to recursively convert an object of data to an array. * * @param object $data An object of data to return as an array. * * @return array Array representation of the input object. * * @since 1.0 */ protected function asArray($data) { $array = array(); if (\is_object($data)) { $data = get_object_vars($data); } foreach ($data as $k => $v) { if (\is_object($v) || \is_array($v)) { $array[$k] = $this->asArray($v); continue; } $array[$k] = $v; } return $array; } /** * Dump to one dimension array. * * @param string $separator The key separator. * * @return string[] Dumped array. * * @since 1.3.0 */ public function flatten($separator = null) { $array = array(); if (empty($separator)) { $separator = $this->separator; } $this->toFlatten($separator, $this->data, $array); return $array; } /** * Method to recursively convert data to one dimension array. * * @param string $separator The key separator. * @param array|object $data Data source of this scope. * @param array $array The result array, it is passed by reference. * @param string $prefix Last level key prefix. * * @return void * * @since 1.3.0 */ protected function toFlatten($separator = null, $data = null, &$array = array(), $prefix = '') { $data = (array) $data; if (empty($separator)) { $separator = $this->separator; } foreach ($data as $k => $v) { $key = $prefix ? $prefix . $separator . $k : $k; if (\is_object($v) || \is_array($v)) { $this->toFlatten($separator, $v, $array, $key); continue; } $array[$key] = $v; } } } Error