@param string|string[]|null $data
@param string               $root

@return array|null
428364
private function getPathsData($data, string $root): ?array
    {
        if ($data === null || !\is_array($data) || \count($data) === 0) {
            return null;
        }

        return $this->existingPaths($data, $root);
    }
1175044
public function filter($roots)
    {
        $datalen = strlen($this->raw_data);
        $roots   = array_flip($roots);
        $result  = '';
        $start   = 0;

        $this->meta          = array();
        $this->meta['count'] = 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);
            $start = $pos + 1;

            // extract root message ID
            if ($npos = strpos($elem, self::SEPARATOR_ITEM)) {
                $root = (int) substr($elem, 0, $npos);
            }
            else {
                $root = $elem;
            }

            if (isset($roots[$root])) {
                $this->meta['count']++;
                $result .= self::SEPARATOR_ELEMENT . $elem;
            }
        }

        $this->raw_data = ltrim($result, self::SEPARATOR_ELEMENT);
    }
1143154
protected static function arrayToXmlInternal($data, $root = null, $level = 1, $format = true)
    {
        $xml = null;
        if (is_array($data)) {
            if (!Arr::isAssoc($data)) {
                foreach ($data as $value) {
                    $xml .= self::arrayToXmlInternal($value, $root, $level, $format);
                }
            } else {
                if (Arr::isAssoc($data)) {
                    if (!empty($root)) {
                        if ($format) {
                            $xml .= str_repeat("\t", $level - 1);
                        }
                        $xml .= "<$root>";
                        if ($format) {
                            $xml .= "\n";
                        }
                    }
                    foreach ($data as $key => $value) {
                        $xml .= self::arrayToXmlInternal($value, $key, $level + 1, $format);
                    }
                    if (!empty($root)) {
                        if ($format) {
                            $xml .= str_repeat("\t", $level - 1);
                        }
                        $xml .= "</$root>";
                        if ($format) {
                            $xml .= "\n";
                        }
                    }
                } else {
                    // empty array
                    if (!empty($root)) {
                        if ($format) {
                            $xml .= str_repeat("\t", $level - 1);
                        }
                        $xml .= "<$root></$root>";
                        if ($format) {
                            $xml .= "\n";
                        }
                    }
                }
            }
        } elseif (is_object($data)) {
            if ($data instanceof Arrayable) {
                $xml .= self::arrayToXmlInternal($data->toArray(), $root, $level, $format);
            } else {
                $dataString = (string)$data;
                if (!empty($root)) {
                    if ($format) {
                        $xml .= str_repeat("\t", $level - 1);
                    }
                    $xml .= "<$root>$dataString</$root>";
                    if ($format) {
                        $xml .= "\n";
                    }
                }
            }
        } else {
            // not an array or object
            if (!empty($root)) {
                if ($format) {
                    $xml .= str_repeat("\t", $level - 1);
                }
                $xml .= "<$root>";
                if (!is_null($data)) {
                    if (is_bool($data)) {
                        $xml .= ($data) ? 'true' : 'false';
                    } else {
                        if (is_int($data) || is_float($data)) {
                            $xml .= $data;
                        } else {
                            if (is_string($data)) {
                                $htmlValue = htmlspecialchars($data, ENT_QUOTES, 'UTF-8');
                                $xml .= $htmlValue;
                            }
                        }
                    }
                }
                $xml .= "</$root>";
                if ($format) {
                    $xml .= "\n";
                }
            }
        }

        return $xml;
    }
37701
public function xml_encode($data, $root='xml', $item='item', $attr='', $id='id', $encoding='utf-8') {
        if(is_array($attr)){
            $_attr = array();
            foreach ($attr as $key => $value) {
                $_attr[] = "{$key}=\"{$value}\"";
            }
            $attr = implode(' ', $_attr);
        }
        $attr   = trim($attr);
        $attr   = empty($attr) ? '' : " {$attr}";
        $xml   = "<{$root}{$attr}>";
        $xml   .= self::data_to_xml($data, $item, $id);
        $xml   .= "</{$root}>";
        return $xml;
    }
935926
public static function fromArray( $data, $rootName = null, $nodeName = null, $addHeader = true )
    {
        $_xml = true === $addHeader ? '<?xml version="1.0" encoding="UTF-8" ?>' : null;

        if ( null !== $rootName )
        {
            $_xml .= Markup::openTag( $rootName );
        }

        $_string = null;

        if ( $data instanceof \Traversable )
        {
            foreach ( $data as $_key => $_value )
            {
                if ( is_numeric( $_key ) )
                {
                    $_key = $nodeName ?: 'node';
                }

                $_string .= Markup::tag( $_key, array(), static::fromArray( $_value, $nodeName ) );
            }
        }
        else
        {
            $_string = htmlspecialchars( $data, ENT_QUOTES );
        }

        //	Add the converted XML
        $_xml .= $_string;

        if ( null !== $rootName )
        {
            $_xml .= Markup::closeTag( $rootName );
        }

        return $_xml;
    }
1182764
public static function get(array $root, string $key){
        $nodes  = self::getMatchedNodes($root, $key);

        if(empty($nodes)){
            return null;
        }else if(count($nodes) === 1){
            return array_pop($nodes);
        }

        return $nodes;
    }
466551
static function load($root = NULL)
  {
    if ($root === NULL)
    {
      $root = realpath(dirname(__FILE__));
    }

    $files = array(
      'Compiler',
      'Error',
      'Helpers',
      'Lexer',
      'Nodes',
      'Parser',
      'Rewriter',
      'Scope',
      'SyntaxError',
      'Value',

      'yy/Base',  // load the base class first
      'yy/While', // For extends While

      'yy/Access',
      'yy/Arr',
      'yy/Assign',
      'yy/Block',
      'yy/Call',
      'yy/Class',
      'yy/Closure',
      'yy/Code',
      'yy/Comment',
      'yy/Existence',
      'yy/Extends',
      'yy/For',
      'yy/If',
      'yy/In',
      'yy/Index',
      'yy/Literal',
      'yy/Obj',
      'yy/Op',
      'yy/Param',
      'yy/Parens',
      'yy/Range',
      'yy/Return',
      'yy/Slice',
      'yy/Splat',
      'yy/Switch',
      'yy/Throw',
      'yy/Try',
      'yy/Value',
    );

    foreach ($files as $file)
    {
      require_once "$root/$file.php";
    }
  }
789205
public function getParsedData($key = null)
    {
        $result = null;

        if ($this->parsedData !== null && is_array($this->parsedData)) {
            if (null === $key) {
                $result = $this->parsedData;
            } else {
                $result = (isset($this->parsedData[$key])) ? $this->parsedData[$key] : null;
            }
        }

        return $result;
    }
456328
public function data($data = []) {
        if (count($data) == 0) {
            return $this->_data;
        }
        else {
            $this->_data = $data;
        }

        return null;
    }
856415
public static function readDataKey($data, $key)
    {
        return isset($data->{$key}) ? (string)$data->{$key} : null;
    }
69483
public static function fetch($path, $root) {
      $_ = (array)$root;
      if (strpos($path,'.') === false) {
        return isset($_[$path]) ? $_[$path] : null;
      } else {
        list($frag,$rest) = explode('.', $path, 2);
        if ($rest) {
          return isset($_[$frag]) ? self::fetch($rest, $_[$frag]) : null;
        } elseif ($frag) {
          return (array)$_[$frag];
        } else {
          return null;
        }
      }
    }
929140
protected function deleteFolderContent($data, $root = '', $force = false)
    {
        $root = FileUtilities::fixFolderPath($root);
        $out = [];
        if (!empty($data)) {
            foreach ($data as $key => $resource) {
                $path = array_get($resource, 'path');
                $name = array_get($resource, 'name');

                if (!empty($path)) {
                    $fullPath = $path;
                } else {
                    if (!empty($name)) {
                        $fullPath = $root . '/' . $name;
                    } else {
                        throw new BadRequestException('No path or name provided for resource.');
                    }
                }

                switch (array_get($resource, 'type')) {
                    case 'file':
                        $out[$key] = ['name' => $name, 'path' => $path, 'type' => 'file'];
                        try {
                            $this->driver->deleteFile($this->container, $fullPath);
                        } catch (\Exception $ex) {
                            $out[$key]['error'] = ['message' => $ex->getMessage()];
                        }
                        break;
                    case 'folder':
                        $out[$key] = ['name' => $name, 'path' => $path, 'type' => 'folder'];
                        try {
                            $this->driver->deleteFolder($this->container, $fullPath, $force);
                        } catch (\Exception $ex) {
                            $out[$key]['error'] = ['message' => $ex->getMessage()];
                        }
                        break;
                }
            }
        }

        return $out;
    }
1240369
public function load($file, $data = null)
    {
        $data = array_merge($this->data, (array) $data);

        $renderer = $this->createSelf();

        return $renderer->render($file, $data);
    }
43996
private function parseAdminBarTree( $tree, $root = null ) {
		$return = [];
		foreach ( $tree as $child => $parent ) {
			if ( $parent === $root ) {
				//  Remove item from tree (we don't need to traverse this again)
				unset( $tree[ $child ] );
				// Append the child into result array and parse its children
				$return[] = [
					'name' => $child,
					'children' => $this->parseAdminBarTree( $tree, $child ),
				];
			}
		}
		return empty( $return ) ? null : $return;
	}
1101713
public function fetchTree($rootId=null, $depth=null)
    {
        $wrappers = $this->fetchTreeAsArray($rootId, $depth);

        return (!is_array($wrappers) || empty($wrappers)) ? null : $wrappers[0];
    }
1143959
public function getSafeArray(string $key, array & $data, string $default = null)
    {
        $value = $this->getFromArray($key, $data, $default);

        return \htmlspecialchars($value);
    }
1224279
private function getDocument($root = null)
    {
        return $this->document !== null ? $this->document : $this->document = $this->createDocument($root);
    }