@param string $file

@return RefClass[]
@throws RuntimeException
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();
    }
766356
public function analyze_js(string $file): array
  {
    $res = [];
    $js = file_get_contents($file);
    if ( $tmp = \Gettext\Translations::fromJsCodeString($js, [
      'functions' => [
        '_' => 'gettext',
        'bbn._' => 'gettext'
      ],
      'file' => $file
      ]) ){
      foreach ( $tmp->getIterator() as $r => $tr ){
        $res[] = $tr->getOriginal();
      }
      $this->parser->mergeWith($tmp);
    }
    return array_unique($res);
  }
261719
public function listVersionsToOriginal(File $file)
    {
        if(!$this->containsFile($file)){
            return array();
        }

        if($this->isVersion($file)){
            return array();
        }

        return array_filter($file->getParentFolder()->listFolder(Folder::LIST_FOLDER_FILES), function(File $f) use ($file){
            return $this->isVersion($f) && strpos($f->getBasename(), $file->getBasename()) === 0;
        });
    }
464773
private function calculateFilesReferencingFile(Codebase $codebase, $file)
    {
        $referenced_files = [];

        $file_classes = ClassLikeAnalyzer::getClassesForFile($codebase, $file);

        foreach ($file_classes as $file_class_lc => $_) {
            if (isset(self::$file_references_to_classes[$file_class_lc])) {
                $referenced_files = array_merge(
                    $referenced_files,
                    array_keys(self::$file_references_to_classes[$file_class_lc])
                );
            }
        }

        return array_unique($referenced_files);
    }
490172
public function resolveClassname($file)
    {

        $splFile = new SplFileInfo($file);
        $parts   = explode('_', $splFile->getFilename());
        $strings = [];
        foreach ($parts as $part) {
            if (is_numeric($part)) {
                continue;
            }
            array_push($strings, $part);
        }
        $class = Str::studly(implode('_', $strings));
        return new $class;
    }
607335
public static function parseFile($file)
    {
        if (!file_exists($file) || !is_readable($file)) {
            $message = "crontab config file is not exists or not readable";
            throw new \RuntimeException($message);
        }

        $tasks = array();
        $lines = file($file);
        foreach ($lines as $line) {
            $job = new JobParse($line);
            $tasks[] = $job->getTask();
        }

        return $tasks;
    }
117620
public static function find(String $file, String $data) : stdClass
    {
        $contents = self::read($file);
        $index    = strpos($contents, $data);

        return (object)
        [
            'index'    => $index,
            'contents' => $contents
        ];
    }
533595
protected function rename($file)
    {
        $tmpFile = $file . '.tmp';

        if (rename($file, $tmpFile)) {
            return $tmpFile;
        }

        throw new \RuntimeException(sprintf('Could not rename %s to %s', $file, $tmpFile));
    }
277821
public function toFile($file)
	{
		$minified = $this->minify();

		// Create dir
		$dir = dirname($file);

		if (!is_dir($dir))
		{
			if (is_file($dir))
			{
				throw new \RuntimeException(sprintf('Path: %s is already a file.', $dir));
			}

			if (!@mkdir($dir, 0755, true) && !is_dir($dir))
			{
				throw new \RuntimeException(sprintf('Auto create dir: %s fail.', $dir));
			}
		}

		file_put_contents($file, $minified);

		return $this;
	}
181766
public static function rmfile($file)
    {
        if (is_file($file)) {
            return chmod($file, 0777) && unlink($file);
        } else {
            throw new RuntimeException(sprintf(
                'Invalid file path supplied "%s"', $file
            ));
        }
    }
158657
public static function read( $fileName )
	{
		$list	= array();
		if( !file_exists( $fileName ) )
			throw new RuntimeException( 'File "'.$fileName.'" is not existing' );
		$reader	= new FS_File_Reader( $fileName );
		$lines	= $reader->readArray();
		foreach( $lines as $line )
			if( $line = trim( $line ) )
				if( !preg_match( self::$commentPattern, $line ) )
					$list[]	= $line;
		return $list;
	}
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;
    }
262383
protected function loadMappingFile($file)
    {
        $result     = [];
        $xmlElement = simplexml_load_file($file);

        if (isset($xmlElement->entity)) {
            foreach ($xmlElement->entity as $entityElement) {
                $entityName          = (string) $entityElement['name'];
                $result[$entityName] = $entityElement;
            }
        }

        return $result;
    }
916275
private function findMediaObjectsForMediaFile(string $file): array
    {
        return DB::table('media')
            ->join('media_file', static function (JoinClause $join): void {
                $join
                    ->on('media_file.m_file', '=', 'media.m_file')
                    ->on('media_file.m_id', '=', 'media.m_id');
            })
            ->join('gedcom_setting', 'media.m_file', '=', 'gedcom_setting.gedcom_id')
            ->where(DB::raw('setting_value || multimedia_file_refn'), '=', $file)
            ->select(['media.*'])
            ->distinct()
            ->get()
            ->map(Media::rowMapper())
            ->all();
    }
561955
public function getFileClass($file)
    {
        $sections = explode(DIRECTORY_SEPARATOR, $file);
        $fileName = $sections[count($sections) - 1];

        $class = str_replace('.php', '', $fileName);

        return $class;
    }
777608
protected function getContents(File $file)
    {
        $level = error_reporting(0);
        $content = file_get_contents($file->getPathname());
        error_reporting($level);
        if (false === $content) {
            $error = error_get_last();
            throw new \RuntimeException($error['message']);
        }

        return $content;
    }
119285
public static function getFileContents(string $file) : string
    {
        if (!is_readable($file)) {
            throw new RuntimeException(sprintf(
                'File "%s" does not exist or is not readable',
                $file
            ));
        }

        $contents = file_get_contents($file);
        if ($contents === false) {
            throw new RuntimeException(sprintf(
                'Could not read from existing and readable file "%s"',
                $file
            ));
        }

        return $contents;
    }