Первый существующий файл

@param string[] $files
@return string|null
484220
public static function getFirstExistingFileArray($files = [])
    {
        foreach ($files as $file) {
            if (file_exists(\Yii::getAlias($file))) {
                return $file;
            }
        }

        return null;
    }
872301
protected function doLoad(array $files, $extends = null)
    {
        $filename = array_shift($files);
        $content = $this->loadFile($filename);

        $key = '';
        if (isset($content['extends@'])) {
            $key = 'extends@';
        } elseif (isset($content['@extends'])) {
            $key = '@extends';
        } elseif (isset($content['@extends@'])) {
            $key = '@extends@';
        }

        $override = (bool)$extends;
        $extends = (array)($key && !$extends ? $content[$key] : $extends);

        unset($content['extends@'], $content['@extends'], $content['@extends@']);

        $data = $extends ? $this->doExtend($filename, $files, $extends, $override) : [];
        $data[] = $content;

        return $data;
    }
755367
public static function convert($files)
    {
        $result = array();
        foreach ($files as $key => $file) {
            if (isset($file['tmp_name'])) {
                if (is_string($file['tmp_name'])) {
                    $result[$key] = new UploadedFile($file);
                    continue;
                }
                if (is_array($file['tmp_name'])) {
                    if (isset($file['tmp_name'][0]) and is_string($file['tmp_name'][0])) {
                        $result[$key] = array();
                        foreach ($file['tmp_name'] as $offset => $tmpName) {
                            $result[$key][] = new UploadedFile($file, $offset);
                        }
                        continue;
                    }
                }
            }
            $result[$key] = self::convert($file);
        }
        return $result;
    }
1125686
public function setFiles($files)
    {
        $this->_files = array();
        $token        = ' ,;';
        $file         = strtok($files, $token);

        while ($file !== false) {
            $this->_files[] = $file;
            $file           = strtok($token);
        }

    }
1179335
protected function prepareFiles($files) {
    $values = [];

    foreach ($files as $file_uuid) {
      $file = $this->fileStorage->loadByProperties([
        'uuid' => $file_uuid,
      ]);

      if ($file) {
        $values[] = [
          'target_id' => current($file)->id(),
        ];
      }
    }

    return $values;
  }
250391
public static function js_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n// Cannot read JS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."\n\n";
                continue;
            }
            $compressed[] = self::js($content);
        }

        return implode(";\n", $compressed);
    }
436071
public function load(array $files = null) : ApplicationInterface
    {
        $this->callLoad($files) || parent::load($files);

        return $this;
    }
1105759
private function getTableRows($files)
    {
        $rows = [];

        foreach ($files as $file => $keys) {
            $rows[] = [count($keys), $file];
        }

        return $rows;
    }
1129949
public function file( $name = '' )
	{
		if( is_array( $name ) ){
			return $this->file = array_merge( $this->file, $name );
		}
		$files = $this->file;
		if( !empty( $files ) ){
			if( $name == '' ){
				return $files;
			} else{
				return $files[$name];
			}
		}
		return null;
	}
953179
public function set(array $files)
    {
        if (!empty($files)) {
            foreach ($files as $_file) {
                if (is_array($_file) && isset($_file['file'])) {
                    $this->add(
                        $_file['file'],
                        isset($_file['media']) ? $_file['media'] : '',
                        isset($_file['condition']) ? $_file['condition'] : null
                    );
                } elseif (is_string($_file)) {
                    $this->add($_file);
                }
            }
        }
        return $this;
    }
784127
public static function deserializeFromFile($file)
  {
    if (file_exists($file))
    {
      $serialized_data = file_get_contents($file);
      return unserialize($serialized_data);
    }
    else return null;
  }
1318411
public static function css_files(array $files) {
        if (empty($files)) {
            return '';
        }

        $compressed = array();
        foreach ($files as $file) {
            $content = file_get_contents($file);
            if ($content === false) {
                $compressed[] = "\n\n/* Cannot read CSS file ".basename(dirname(dirname($file))).'/'.basename(dirname($file)).'/'.basename($file)."*/\n\n";
                continue;
            }
            $compressed[] = self::css($content);
        }

        return implode("\n", $compressed);
    }
149879
public function bind($files)
	{
		try
		{
			$files = str_replace(array(" ", "\t", "\n"), "", $files);
			$id = md5($files);
			$files = explode(",", trim($files, ","));

			if ($this->debug)
				return $this->generateDebugLink($files);

			if ($this->documentRootDir)
				$dr = $this->documentRootDir;
			else
				$dr = $_SERVER["DOCUMENT_ROOT"];

			$outDir = "{$dr}{$this->outdir}";

			if (!is_dir($outDir))
				throw new \Exception("Asset directory doesn't exist {$outDir}");

			if (!$files)
				throw new \Exception ("Parameter 'files' is not defined");

			if (count($files) == 0)
				throw new \Exception ( "You have to set a file at least");


			$outputFile = "{$outDir}/{$id}.js";
			$metaFile = "{$outDir}/{$id}.meta";

			$now = time();
			$hash = null;
			$storedHash = null;

			if (!is_file($metaFile) || $this->ttl == 0)
			{
				list($mtimes, $fileList) = $this->generateInfo($files);

				$this->writeMeta($metaFile, $mtimes, $now);
				$this->compileAssets($fileList, $outputFile);
				return $this->generateLink($this->outdir, $id, $mtimes);
			}
			else
			{
				$meta = file_get_contents($metaFile);

				list($storedHash, $age) = explode(":", $meta);
				if ((intval($age) + $this->ttl) < $now)
				{
					list($mtimes, $fileList) = $this->generateInfo($files);
					$this->writeMeta($metaFile, $mtimes, $now);

					if ($mtimes !== $storedHash)
					{
						$this->compileAssets($fileList, $outputFile);
						return $this->generateLink($this->outdir, $id, $mtimes);
					}
				}
				return $this->generateLink($this->outdir, $id, $storedHash);
			}
		}
		catch (\Exception $e)
		{
			return "Assets error: " . $e->getMessage();
		}
	}
437345
public function loadFiles($files)
    {
        $files = (array) $files;

        $success = true;
        foreach ($files as $file) {

            $this->loadFile($file);
        }
        return true;
    }
863962
protected function getCountForFiles(array $files)
    {
        $analyserClass = '\\SebastianBergmann\\PHPLOC\\Analyser';
        $analyser = new $analyserClass();

        return $analyser->countFiles($files, $this->countTests);
    }
1198301
protected function loader($file)
    {
        foreach ($this->folders as $folder)
        {
            foreach (FileLoader::extensions() as $ext)
            {
                try
                {
                    return FileLoader::load($folder . '/' . $file . '.' . $ext);
                }
                catch (\Throwable $throwable)
                {
                    // skip...
                }
            }
        }

        return null;
    }
1251984
protected function loadConfigFile($file)
    {
        $path = $this->getConfigPath() . '/' . $file;

        if (file_exists($path)) {
            $config = include $path;
            return is_array($config) ? $config : null;
        }

        return null;
    }