Parse a navigation.yml file

@param string $file

@return array
187719
public function parseFile($file)
    {
        $bundleConfig = Yaml::parse(file_get_contents(realpath($file)));

        if (!is_array($bundleConfig)) {
            return array();
        }

        return $bundleConfig;
    }
1309762
public static function grab_deps( $file ) {
		if ( ! file_exists( $file ) ) {
			return [];
		}
		// @see {wp-includes/functions.php}
		$fp = fopen( $file, 'r' );
		$file_header = fread( $fp, 8192 );
		fclose( $fp );
		// Make sure we catch CR-only line endings.
		$file_header = str_replace( "\r", "\n", $file_header );
		// Grab dependencies.
		$regexp = '#wpdeps=(.*)$#um';
		if ( ! preg_match_all( $regexp, $file_header, $matches ) ) {
			return [];
		} else {
			list( $match, $deps ) = $matches;
			$deps = [];
			foreach ( $matches[1] as $dep ) {
				foreach ( array_map( 'trim', explode( ',', $dep ) ) as $d ) {
					if ( $d ) {
						$deps[] = $d;
					}
				}
			}
			return $deps;
		}
	}
502306
private function parseYml()
    {
        if (!file_exists($this->path)) {
            touch($this->path);
        }

        return $this->yml->parse(file_get_contents($this->path));
    }
968466
protected function parse_file($file = null) {
        if (is_null($file)) {
            $file = $this->file;
        }

        if (empty($this->file_data)) {
            $this->load_data($file);
        }

        return !empty($this->file_data) ? $this->parse_string() : false;
    }
224297
public function parse(string $file): array
    {
        if (false === file_exists($file)) {
            throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
        }

        try {
            $data = defined('Symfony\\Component\\Yaml\\Yaml::PARSE_CONSTANT')
                ? $this->yamlParser->parse(file_get_contents($file), Yaml::PARSE_CONSTANT)
                : $this->yamlParser->parse(file_get_contents($file));

            // $data is null only if the YAML file was empty; otherwise an exception is thrown
            return (null === $data) ? [] : $data;
        } catch (\Exception $exception) {
            if ($exception instanceof SymfonyParseException) {
                throw ParseExceptionFactory::createForInvalidYaml($file, 0, $exception);
            }

            throw ParseExceptionFactory::createForUnparsableFile($file, 0, $exception);
        }
    }
138278
protected static function convertFile($file)
    {
        $error = $file->getError();
        $tmpName = '';
        if ($error === UPLOAD_ERR_OK) {
            $tmpName = $file->getStream()->getMetadata('uri');
        }

        return [
            'name' => $file->getClientFilename(),
            'type' => $file->getClientMediaType(),
            'tmp_name' => $tmpName,
            'error' => $error,
            'size' => $file->getSize(),
        ];
    }
803076
private static function parseRequestedFile(string $file): array
    {
        $file = ltrim($file, '/');

        $moduleConfig = Config::application('module');

        $parts    = explode('/', $file);
        $partsCnt = count($parts);

        if ($partsCnt > 0 && in_array($parts[0], Config::get('divisions'))) {
            $_division = $parts[0];
            $parts     = array_slice($parts, 1);
        } else {
            $_division = '';
        }

        $_module = empty($parts[0])
            ? $moduleConfig['default']
            : $parts[0];

        $_method = $partsCnt < 2 || empty($parts[1])
            ? $moduleConfig['defaultViewsControllerAction']
            : Str::camel($parts[1]);

        $_params = $partsCnt > 2
            ? array_slice($parts, 2)
            : [];

        return [$_division, $_module, $_method, $_params];
    }
34265
private function getData(string $file): array
  {
    static $RESULT_STOP_WORDS_CACHE = array();

    if (isset($RESULT_STOP_WORDS_CACHE[$file])) {
      return $RESULT_STOP_WORDS_CACHE[$file];
    }

    $file = __DIR__ . '/stopwords/' . $file . '.php';
    if (file_exists($file)) {
      /** @noinspection PhpIncludeInspection */
      $RESULT_STOP_WORDS_CACHE[$file] = require $file;
    } else {
      $RESULT_STOP_WORDS_CACHE[$file] = array();
    }

    return $RESULT_STOP_WORDS_CACHE[$file];
  }
1069890
public function parse($file)
    {
        $result = null;
        $this->hook->attach('help.render.before', $file, $result, $this);

        if (isset($result)) {
            return (string) $result;
        }

        $result = $this->markdown->render(file_get_contents($file));
        $this->hook->attach('help.render.after', $file, $result, $this);
        return (string) $result;
    }
44835
public function loadFile($file)
    {
        if (is_array($file)) {
            return collect($file)->mapWithKeys(function ($subFile, $key) {
                return [$key => $this->loadFile($subFile)];
            })->toArray();
        }

        return $this->parser->parseFile($file);
    }
1250906
protected function parse(\SplFileInfo $file): array
    {
        libxml_use_internal_errors(true);

        $xml = simplexml_load_file($file->getRealPath());
        if (!$xml instanceof \SimpleXMLElement) {
            $errors = array_map(function (\LibXMLError $error) {
                return trim($error->message);
            }, libxml_get_errors());
            libxml_clear_errors();

            throw new ConfigurationParseException('Unable to parse config file: ' . implode(', ', $errors));
        }

        $config = json_decode(json_encode($xml), true);

        return $config;
    }
955994
public function parse(string $file): array
    {
        if (false === file_exists($file)) {
            throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
        }

        try {
            $data = json_decode(file_get_contents($file), true);

            if (null === $data) {
                throw ParseExceptionFactory::createForInvalidJson($file);
            }

            return $data;
        } catch (\Exception $exception) {
            if ($exception instanceof UnparsableFileException) {
                throw $exception;
            }

            throw ParseExceptionFactory::createForUnparsableFile($file, 0, $exception);
        }
    }
49976
protected function getTranslations(string $file) : array
    {
        return $this->files->exists($file) ? (array) json_decode($this->files->get($file)) : [];
    }
1306200
protected static function loadFromFile(?string $file)
    {
        if ($file === null) {
            return [];
        }

        $ext = \strrchr($file, '.');
        if ($ext === '.yml' || $ext === '.yaml') {
            return static::loadYaml($file, $ext);
        }

        return require $file;
    }
1017421
public static function getFile( $file ) {
		$file = Storage::getFile( Route::DOCUMENT_ROOT() . 'app/config/' . $file . '.json' );
		$out  = Parser::json( $file );

		return $out;
	}
1105308
private function parseIniFile(string $file): array
    {
        $ini = parse_ini_file($file, true);

        if (!\is_array($ini)) {
            throw new \RuntimeException("File $file cannot be decoded");
        }

        if (!isset($ini['requires']) || !\is_array($ini['requires'])) {
            return [];
        }

        return $ini['requires'];
    }
905275
public function loadFile(string $file) : array
    {
        if (!file_exists($file)) {
            throw new LoaderException("Requested YAML file '{$file}' doesn't exist");
        }

        if (!$this->forceSymfony && $this->hasExtension) {
            $data = yaml_parse_file($file);
        } else {
            $data = Yaml::parse(file_get_contents($file));
        }

        if (!is_array($data)) {
            throw new LoaderException("Requested YAML file '{$file}' does not parse to an array");
        }

        return $data;
    }