Parse File
Read file to string and call parse_string()

@param  string|null $file Local CSV file

@return array|bool
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;
    }
1332695
protected function parseFromFile(string $file) : array
    {
        if (function_exists('yaml_parse_file')) {
            try {
                set_error_handler(function ($code, $message) {
                    throw new \RuntimeException(
                        $message,
                        $code
                    );
                });

                $array = yaml_parse_file($file);
                restore_error_handler();
                if (!is_array($array)) {
                    throw new \RuntimeException(
                        sprintf(
                            'Configuration file in : %s does not return array',
                            $file
                        )
                    );
                }
                return $array;
            } catch (\Throwable $e) {
                restore_error_handler();
                throw  $e;
            }
        }

        $array =  SymfonyYAML::parse(file_get_contents($file));
        if (!is_array($array)) {
            throw new \RuntimeException(
                sprintf(
                    'Configuration file in : %s does not return array',
                    $file
                )
            );
        }

        return $array;
    }
368753
static function read($file)
	{
		if(file_exists($file) && is_readable($file))
			return file_get_contents($file);

		foreach(bors_dirs() as $dir)
			if(file_exists($fn = $dir.'/data/'.$file) && is_readable($fn))
				return file_get_contents($fn);

		return NULL;
	}
295529
public function loadFile($file = null)
    {
        if (null === $file) {
            $file = $this->getDefaultPath();
        }

        $json = $this->json->decodeFile($file);

        if (isset($json->import)) {
            if (!Path::isAbsolute($json->import)) {
                $json->import = Path::join(
                    array(
                        dirname($file),
                        $json->import
                    )
                );
            }

            $json = (object) array_merge(
                (array) $this->json->decodeFile($json->import),
                (array) $json
            );
        }

        $this->json->validate(
            $this->json->decodeFile(BOX_SCHEMA_FILE),
            $json
        );

        return new Configuration($file, $json);
    }
1098926
protected function parseFileContents($file)
    {
        try {

            $data = $this->files->get($file);

        } catch (FileNotFoundException $e) {

            throw new CouldNotConnectException("Local file could not be found: '{$file}'");

        } catch (Exception $e) {

            throw new CouldNotConnectException("Local file unreadable or unopenable: '{$file}'");
        }

        // store the file name as the request method, so the interpreter can know what the source was;
        $this->request->setMethod(basename($file));

        // add information to mark reading the file a success
        $information = new ServiceResponseInformation();
        $information->setStatusCode(200);

        return $this->interpreter->interpret($this->request, $data, $information);
    }
506659
protected function parseFile($file)
    {
        $stmts = $this->phpParser->parse(file_get_contents($file));

        $visitor = new RefVisitor($file);
        $this->traverser->addVisitor($visitor);
        $this->traverser->traverse($stmts);
        $this->traverser->removeVisitor($visitor);

        return $visitor->getClasses();
    }
1299034
public function parse(string $file): array
    {
        if (false === file_exists($file)) {
            throw InvalidArgumentExceptionFactory::createForFileCouldNotBeFound($file);
        }

        $data = include $file;

        if (false === is_array($data)) {
            throw TypeErrorFactory::createForInvalidFixtureFileReturnedData($file);
        }

        return $data;
    }
1273228
protected function readFile(string $file) : string
    {
        if (is_file($file) === false) {
            throw new BadFileException("The file \"{$file}\" is not a file.", $file);
        }

        if (is_readable($file) === false) {
            throw new BadFileException("Unable to open \"{$file}\" as the file is not readable.", $file);
        }

        return file_get_contents($file);
    }
88180
public static function for_file($file)
    {
        if (!$file || (is_string($file) && !file_exists($file))) {
            return null;
        }

        // Ensure we have a File instance to work with
        if (is_string($file)) {
            /** @var File $fileObject */
            $fileObject = File::create();
            $fileObject->setFromLocalFile($file);
            $file = $fileObject;
        }

        $extension = $file->getExtension();
        $mime = $file->getMimeType();

        foreach (self::get_extractor_classes() as $className) {
            $extractor = self::get_extractor($className);

            // Skip unavailable extractors
            if (!$extractor->isAvailable()) {
                continue;
            }

            // Check extension
            if ($extension && $extractor->supportsExtension($extension)) {
                return $extractor;
            }

            // Check mime
            if ($mime && $extractor->supportsMime($mime)) {
                return $extractor;
            }
        }
    }
41740
public function loadFile($file)
    {
        $openfile = @fopen($file, "rb") or die("loadFile: Error opening file '{$file}'.");
        $contents = @fread($openfile, filesize($file)) or die("loadFile: Error reading data from file '{$file}'.");
        @fclose($openfile);
        return $contents;
    }
649375
public function parseFile($file)
    {
        $handle = @fopen($file, 'r');
        if (!$handle) {
            throw new ErrorException(sprintf('Unable to open %s', $file));
        }
        try {
            $this->reset();
            while (!feof($handle)) {
                $buffer = fread($handle, 128);
                $this->parse($buffer);
            }
            $this->throwExceptionIfReadingEntry("\0");
        } finally {
            fclose($handle);
        }
    }
634308
private static function parse(File $file) {

		$lines 		= explode("\n", $file -> getContent());
		$languages 	= [];

		foreach($lines as $index => $line) {
			
			$line = trim($line);

			if('' === $line) {
				continue;
			}

			//Check for language format
			preg_match('#^\[([a-z_\-0-9]+)\]#i', $line, $language);

			if(count($language) === 2) {
				
				$lg = $language[1];
				$languages[$lg] = [];

				continue;
			}

			//If there is no language found
			if(false === isset($lg)) {
				return trigger_error(sprintf('Missing language title in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
			}
			
			//Match the format (key value) on a single translation line
			preg_match('#^(\'|")(.*)(\1)\s+(\'|")(.*)(\3)$#', $line, $match);

			if(count($match) !== 7) {
				return trigger_error(sprintf('Incorrect format in translation file "%s" on line %s', $file -> entity() -> getBasepath(), ++$index), E_USER_ERROR);
			}

			$languages[$lg][$match[2]] = $match[5];
		}

		return $languages;
	}
613733
private function decode($file)
	{
		$json = @\file_get_contents($file);
		if ($json === false) {
			$this->error = $this->error ?: \error_get_last()['message'];

			return null;
		}

		try {
			return Json::decode($json);
		} catch (JsonException $e) {
			$this->error = $this->error ?: $e->getMessage();

			return null;
		}
	}
710473
public function parse($file, $use_include_path = true)
	{
		$this->getPathInfo($file, $use_include_path);

		$this->fopen($this->absolute_path, false);

		switch (strtolower($this->extension)) {
			case 'json':
				return json_decode($this->fileGetContents());

			case 'ini':
				return (object)parse_ini_string($this->fileGetContents(), true);

			case 'xml':
				return simplexml_load_string($this->fileGetContents());
			case 'csv':
				return $this->fileGetCSV();

			default:
				throw new \InvalidArgumentException(
					"{$this->extension} is not a supported extension."
				);
		}
	}
903942
function readFile($file)
	{
		$fh = @fopen($file, 'r');

		$lines = false;
		if ($fh !== false) {
			$lines = array();
			while (!feof($fh)) {
				$lines[] = fgets($fh);
			}
			fclose($fh);
		}
		return $lines;
	}
775084
public static function parse($file)
    {
        $config_path = self::$config_path == '' ? APP_PATH . '/config/' : self::$config_path;
        if($file == null){
            $file = scandir($config_path);
            foreach ($file as $k => $v)
            {
                unset($file[0], $file[1]);
                if($v == 'routes.php' )
                {
                    unset($file[$k]);
                }
            }
            foreach ($file as $k => $v)
            {
                $name = str_replace('.php', '', $v);
                $file = $config_path . $v;
                $data[$name] = include $file;
            }
        }else{
            $type = $file;
            if(strpos($type, '.')){
                $type = explode('.', $type);
                $file = $config_path . $type[0] . '.php';
                if(!array_key_exists($type[1], self::load($file)))
                {
                    throw new Exception('This configuration [' . self::$config . '] is not supported!');
                }
                $data = self::load($file)[$type[1]];
            }else{
                $file = $config_path . $file . '.php';
                $data = self::load($file);
            }

        }
        return $data;
    }
368359
public static function readFile(string $file): string
    {
        $contents = @\file_get_contents($file);
        
        if ($contents === false) {
            throw new \RuntimeException(\sprintf('File not found: "%s"', $file));
        }
        
        return $contents;
    }