キーにマッチする値をすべて取得する

@param   array   $root
@param   string  $key

@return  mixed[]
488463
private static function getMatchedNodes(array $root, string $key){
        $nodes  = [$root];

        foreach(explode(".", $key) as $key){
            if(empty($nodes)){
                break;
            }

            $newNodes   = [];

            foreach($nodes as $node){
                if(is_array($node)){
                    if($key === "*"){
                        foreach($node as $child){
                            $newNodes[] = $child;
                        }
                    }else if(array_key_exists($key, $node)){
                        $newNodes[] = $node[$key];
                    }
                }
            }

            $nodes  = $newNodes;
        }

        return $nodes;
    }
715796
protected function getData($key)
    {
        $path = $this->path($key);
        if (!$this->fileSystem->isFile($path)) {
            return ['data' => null, 'time' => null];
        }

        $content    = $this->fileSystem->get($path);
        $expire     = substr($content, 0, 10);

        if (time() > $expire) {
            $this->delete($key);
            return ['data' => null, 'time' => null];
        }

        $data = unserialize(substr($content, 10));


        return ['data'=>$data, 'time' => ($expire - time())];
    }
943552
public static function fetch( $array, $key )
    {
        $result = [ ];

        foreach ( explode( '.', $key ) as $segment )
        {
            foreach ( $array as $value )
            {
                $value = ( array ) $value;

                $result[ ] = $value[ $segment ];
            }

            $array = array_values( $result );
        }

        return array_values( $result );
    }
1207279
public function findByKey(string $key) {
        if (!$this->root) {
            return null;
        }

        return $this->root->findByKey($key);
    }
252324
public function all( $keys = null ) {
		$input = array_replace_recursive( $this->input(), $this->all_files() );

		if ( ! $keys ) {
			return $input;
		}

		$results = [];

		foreach ( is_array( $keys ) ? $keys : func_get_args() as $key ) {
			Arr::set( $results, $key, Arr::get( $input, $key ) );
		}

		return $results;
	}
992273
public function flatten(?string $key = null) : array
    {
        $array = new \RecursiveIteratorIterator(
            new \RecursiveArrayIterator((array) $this->get($key))
        );

        $tmp = [];
        foreach ($array as $value) {
            $tmp[] = $value;
        }

        return $tmp;
    }
993404
protected function splitDictionaryRemainderAndPrefix(string $key): array
    {
        [$remainder, $prefix] = $this->splitRemainderAndPrefix($key);

        return [$this->dictionaries[$prefix], $remainder, $prefix];
    }
657906
public function keys() {
    $root = $this->directory;
    if (file_exists($root) && is_readable($root)) {
      return array_diff(scandir($root), array('..', '.'));
    }
    return [];
  }
1135656
private function tokenizeKey($key)
    {
        $containerName = $this->containerName;
        if (false === $this->multiContainerMode) {
            return [$containerName, $key];
        }

        if (false === ($index = strpos($key, '/'))) {
            throw new \InvalidArgumentException(sprintf(
                'Failed to establish container name from key "%s", container name is required in multi-container mode',
                $key
            ));
        }
        $containerName = substr($key, 0, $index);
        $key = substr($key, $index + 1);

        return [$containerName, $key];
    }
669448
protected function parseKey($key) {
        $key = trim($key);
        $data = explode('.', $key);
        $group = trim($data[0]);
        if (1 == count($data)) {
            return [$group, null];
        }

        return [$group, $data[1]];
    }
1046060
protected function resolveKey($key)
    {
        list($key, $validates) = explode('.', $key);

        $validates = explode(':', $validates);
        $validator = $validates[0];
        $attributes = count($validates) > 1 ? explode(';', $validates[1]) : [];

        $negative = false;
        if ($validator[0] === '!') {
            $negative = true;
            $validator = substr($validator, 1);
        }

        return [$key, $validator, $attributes, $negative];
    }
448150
protected function doParsingFromRoot(\SimpleXMLElement $root): array
    {
        $parsedData = [];

        foreach ($root->children() as $file) {
            $parsedData[] = $this->getFileData($file);
        }

        return $parsedData;
    }
273501
protected function getParentChildKeys($key)
    {
        $parts = explode('.', $key);
        $child = array_pop($parts);
        return [implode('.', $parts), $child];
    }
466565
protected function makeUriRelativeTo($uri, $root)
    {
        if (!$root) {
            return $uri;
        }

        if (is_array($uri)) {
            $uris = [];
            foreach ($uri as $u) {
                $uris[] = $this->makeUriRelativeTo($u, $root);
            }
            return $uris;
        }

        if (substr($uri, 0, 1) === '/' || preg_match('/^([a-zA-Z]+:\/\/|[a-zA-Z]:\/|[a-zA-Z]:\\\)/', $uri)) {
            return $uri;
        }
        return rtrim($root, '/') . "/$uri";
    }
1317638
public static function arrayGroup($arr, $key){
        $result = [];
        foreach($arr as $k=>$v){
            $result[$v[$key]][] = $v;
        }
        return $result;
    }
1341120
public function hGetAll($key)
    {
        $fields = $this->getDriver()->hGetAll($key);

        if (empty($fields)) {
            return $fields;
        }

        if ($this->hasMaxSize()) {
            foreach ($fields as $field => $value) {
                if ($this->isSplit($value)) {
                    $fields[$field] = $this->join($this->getMappedKey($key, $field), $value);
                }
            }
        }

        return $fields;
    }
165104
public static function getAllValuesOfKey(array $array, $key)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $values = [];

        foreach ($array as $index => $value) {
            if ($index === $key) {
                $values[] = $value;

                continue;
            }

            if (is_array($value)) {
                $recursiveValues = self::getAllValuesOfKey($value, $key);

                if (!empty($recursiveValues)) {
                    $merged = array_merge($values, $recursiveValues);
                    $values = $merged;
                }
            }
        }

        return $values;
    }