/** * Get the keys of the array. * * @param boolean $recursive * (optional) TRUE to get keys of array elements that are also arrays. * * @return NodeCollection */ public function getKeys($recursive = TRUE) { $keys = new NodeCollection(); $index = 0; foreach ($this->elements->getItems() as $element) { if ($element instanceof ArrayPairNode) { $keys->add($element->getKey()); $value = $element->getValue(); } else { $keys->add(Token::integer($index++)); $value = $element; } if ($recursive && $value instanceof ArrayNode) { $keys->add($value->getKeys($recursive)); } } return $keys; }