Export tree as array.
Terminal nodes become tokens, non terminals branches.
@return array
779735
function export(){
		if( $this->is_terminal() ){
			if( $this->t === $this->value ){
				// scalar token
				return $this->value;
			}
			// PHP Tokenizer style array
			return array( $this->t, $this->value );
		}
		// else is a branch
		$a = array();
		foreach( $this->children as $Child ){
			$a[] = array( $this->t, $Child->export() );
		}
		return $a;
	}
742077
public function exportAsArrayExceptNull()
    {
        $columns = $this->exportAsArray();

        foreach ($columns as $key => $value) {
            if ($value === null) {
                unset($columns[$key]);
            }
        }

        return $columns;
    }
66186
private function collectTopStackNodes()
    {
        $nodes = [];

        while (!$this->stack->isEmpty() && $this->stack->top() instanceof Node) {
            array_unshift($nodes, $this->stack->pop());
        }

        return $nodes;
    }
64705
public function export()
    {
        $result = array();

        foreach ($this->collection as $name => $property) {
            /* @var $property PropertyDefnitionInterface */
            $result[$name] = $property->getRawType();
        }

        return $result;
    }
169340
public function generateTree($nodes)
    {
        $superRoot = count(array_filter($nodes, function (ReadNodeInterface $node) {
            return '-' == $node->getParentId();
        }))? '-': 'root';

        $list = array();
        $list[$superRoot] = array();
        foreach ($nodes as $node) {
            if ($superRoot !== $node->getParentId() && $this->parentInList($node->getParentId(), $nodes)) {
                $list[$node->getParentId()][] = $node;
                continue;
            }
            $list[$superRoot][] = $node;
        }

        $tree = $this->createTree($list[$superRoot], $list);

        return $tree;
    }
1318919
protected function parseTree()
    {
        $string = $this->string;
        if (empty($string)) {
            return array();
        }
        $tree = array();
        $i = 0;
        $length = strlen($string);
        $isBackslash = false;
        $operand = '';
        while ($i <= $length) {
            $char = $string[$i];

            $isAND = ($char == self::AND_DELIMITER);
            $isOR = ($char == self::OR_DELIMITER);
            $isEnd = ($length == $i + 1);

            if ($isEnd) {
                if ($isBackslash && ($isAND || $isOR)) {
                    $operand = substr($operand, 0, -1);
                }
                $operand .= $char;
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_END, self::INDEX_OPERAND => $operand);
                break;
            }

            if ($isAND && !$isBackslash) {
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_AND, self::INDEX_OPERAND => $operand);
                $operand = '';
            } elseif ($isOR && !$isBackslash) {
                $tree[] = array(self::INDEX_BOOL_OPERATOR => self::BOOL_OPERATOR_OR, self::INDEX_OPERAND => $operand);
                $operand = '';
            } else {
                if ($isBackslash && ($isAND || $isOR)) {
                    $operand = substr($operand, 0, -1);
                }
                $operand .= $char;
            }
            $isBackslash = ($char == "\\");
            $i++;
        }
        return $tree;
    }
1009053
private function createTreeArray()
    {
        $tree = [];

        foreach($this->models as $model) {
            $tree[] = [
                'id' => $model->{$this->id},
                'parent_id' => $model->{$this->parent_id},
                'model' => $model,
            ];
        }

        return $tree;
    }
749910
public function get_tree()
    {
        $datalen = strlen($this->raw_data);
        $result  = array();
        $start   = 0;

        while (($pos = @strpos($this->raw_data, self::SEPARATOR_ELEMENT, $start))
            || ($start < $datalen && ($pos = $datalen))
        ) {
            $len   = $pos - $start;
            $elem  = substr($this->raw_data, $start, $len);
            $items = explode(self::SEPARATOR_ITEM, $elem);
            $result[array_shift($items)] = $this->build_thread($items);
            $start = $pos + 1;
        }

        return $result;
    }
998926
public function toArray()
    {
        $data = array(
            'added' => $this->getAdded(true),
            'api' => $this->getApi(),
            'cwd' => $this->getCwd(true),
            'debug' => $this->getDebug(),
            'files' => $this->getFiles(true),
            'list' => $this->getList(),
            'netDrivers' => $this->getNetDrivers(),
            'options' => $this->getOptions(),
            'removed' => $this->getRemoved(true),
            'tree' => $this->getTree(true),
            'uplMaxSize' => $this->getUplMaxSize(),
            'content' => $this->getContent(),
            'size' => $this->getSize(),
            'error' => $this->getError(),
            'dim' => $this->getDim(),
        );

        return array_filter(
            $data,
            function ($var) {
                return !is_null($var);
            }
        );
    }
802849
public function build( $tree )
	{
		$lines	= array();
		$children	= $tree->getChildren();
		foreach( $children as $child )
			foreach( self::buildRecursive( $child ) as $line )
				$lines[]	= $line;
		return implode( self::$lineBreak, $lines );
	}
82412
public function toArray() {
			$array = array();

			foreach ($this->data as $k => $v) {
				$nodes = explode('.', $k);
				$loc = &$array;

				foreach ($nodes as $i => $node)
					if ($i === sizeof($nodes) - 1)
						$loc[$node] = $v;
					else if (!isset($array[$node])) {
						$loc[$node] = array();

						$loc = &$loc[$node];
					}
			}

			return $array;
		}
1286433
public function getSiblings() {
        $parent = $this->getParent();
        if (is_null($parent)) {
            // This is the root node.
            return [];
        }

        $children = $parent->getChildren();
        $index = array_search($this, $children);
        unset($children[$index]);
        return $children;
    }
199706
private function export()
    {
        $exported = new StdClass;
        foreach ($this as $name => $field) {
            if ((new ReflectionProperty($this, $name))->isPublic()) {
                if (is_object($field)) {
                    $traits = class_uses($field);
                    if (isset($traits['Ornament\Model'])
                        || isset($traits['Ornament\JsonModel'])
                    ) {
                        $exported->$name = $field->getPrimaryKey();
                    } else {
                        $exported->$name = "$field";
                    }
                } else {
                    $exported->$name = $field;
                }
            }
        }
        return $exported;
    }
996449
public function toArray() {
		if ($this->_array) {
			return $this->_array;
		}
		$root = $this->documentElement;
		if ($root == 'error') {
			return array(
				0 => array(
					'id' => $root->getAttribute('id'),
					'code' => $root->getAttribute('code'),
					'auxCode' => $root->getAttribute('auxCode'),
					'message' => $root->firstChild->nodeValue
				)
			);
		}
		$this->_array = $this->_toArray($root->childNodes);
		return $this->_array;

	}
170897
public function toArray()
    {
        return [
            'key'      => $this->key(),
            'name'     => $this->name(),
            'script'   => $this->script(),
            'dir'      => $this->direction(),
            'native'   => $this->native(),
            'regional' => $this->regional(),
        ];
    }
691219
public function export_config()
	{
    if ( isset($this->_root_element) ){
      return bbn\str::make_readable($this->_root_element->get_config());
    }
		return bbn\str::make_readable($this->_cfg);
	}
942153
final public function export(): array
    {
        $finalArray = [];
        $mandatoryFields = $this->getMandatoryFields();

        $cleanObject = new $this();
        foreach ($cleanObject as $fieldId => $value) {
            if ($this->$fieldId === $cleanObject->$fieldId) {
                if (\in_array($fieldId, $mandatoryFields, true)) {
                    $missingMandatoryField = new MissingMandatoryField(sprintf(
                        'The field "%s" for class "%s" is mandatory and empty, please correct',
                        $fieldId,
                        \get_class($cleanObject)
                    ));
                    $missingMandatoryField->method = \get_class($cleanObject);
                    $missingMandatoryField->methodInstance = $this;
                    throw $missingMandatoryField;
                }
            } else {
                $finalArray[$fieldId] = $this->$fieldId;
            }
        }

        return $finalArray;
    }