@param string[] $searchedDirs

@return null|string
11795
public function getPhpunitXmlDir($searchedDirs = [])
    {
        $locations = array_merge([$this->getSystemService()->getCurrentWorkingDirectory()], $searchedDirs);
        $path      = null;

        foreach ($locations as $location) {
            if ($this->getFilesystemService()->isReadableFile($location.'/phpunit.xml')) {
                $path = $this->getFilesystemService()->getRealPath($location);
                break;
            }
            if ($this->getFilesystemService()->isReadableFile($location.'/phpunit.xml.dist')) {
                $path = $this->getFilesystemService()->getRealPath($location);
                break;
            }
        }

        return $path ? $path : '.';
    }
667278
public function directories($directory = null, $recursive = false)
    {

        $directories = [ ];

        foreach (Finder::create()->in($directory)->directories() as $dir) {
            $directories[] = $dir->getPathname();
        }

        return $directories;
    }
208840
protected function _findExecutable($search, $file)
    {
        $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
        if (file_exists($file)) {
            return $file;
        }
        foreach ($search as $path) {
            $path = rtrim($path, DIRECTORY_SEPARATOR);
            if (file_exists($path . DIRECTORY_SEPARATOR . $file)) {
                return $path . DIRECTORY_SEPARATOR . $file;
            }
        }
        return null;
    }
664887
public function ls($subdir = '', &$raw = NULL)
    {

        $teststr  = str_replace('\\', '-', $subdir);
        $nub =  (preg_match('/[-?|\/?]*([\w \-]+\.\w{1,4})/', $teststr))?'':'\*';

        $this->execute("ls $subdir".$nub, $raw_ls);

        $raw = $raw_ls;
        $ret = ($raw_ls)? $this->processLS($raw_ls, $subdir):0;
        return $ret;
    }
246749
public static function getFolderAsArray($root)
    {
        if (false === is_dir($root)) {
            return null;
        }

        $result = [];
        $folderContent = scandir($root);

        $dirChecks = [
            true,
            false,
        ];

        foreach ($dirChecks as $dirCheck) {
            foreach ($folderContent as $entry) {
                if (true === in_array($entry, self::getDirSymbols())) {
                    continue;
                }

                $path = sprintf('%s/%s', $root, $entry);
                if ($dirCheck === is_dir($path)) {
                    $result[$entry] = self::getFolderAsArray($path);
                }
            }
        }

        return $result;
    }
1218289
public static function getDataFiles(array $names, $dataDir = null)
    {
        $dirs = ($dataDir === null) ? self::getDataDirs() : [$dataDir];

        return self::getRealFiles($dirs, $names);
    }
1073045
public function mkdirs($dirs)
    {
        if (substr($dirs, 0, 1) == '/') {
            $dirs = substr($dirs, 1);
        }
        if (substr($dirs, -1) == '/') {
            $dirs = substr($dirs, 0, -1);
        }
        $dirs = explode('/', $dirs);
        $curDir = $this->connectionString;
        foreach ($dirs as $dir) {
            $curDir .= '/'.$dir;
            if (!is_dir($curDir)) {
                $this->mkdir($dir);
            }
            $this->chdir($dir);
        }

        return $this;
    }
1122926
private function getFileInfoObjectsInDirs(array $dirs): array
    {
        $finder   = new Finder();
        $iterable = $finder->files()->in($dirs);

        return iterator_to_array($iterable);
    }
296027
public function searchCacheDir(File $origDir) {
        if (isset($this->autoDirPathMap[\md5($origDir->getAbsolutePath())])) {
            $entry = $this->autoDirPathMap[\md5($origDir->getAbsolutePath())];
            return $entry[1];
        } else {
            return null;
        }
    }
889530
public static function removeDirectories($directories = null)
	{
		if (is_null($directories))
		{
			static::$directories = array();
		}
		else
		{
			static::$directories = array_diff(static::$directories, (array) $directories);
		}
	}
539730
public function addSearchDirs($dirs)
    {
        // just force to array
        settype($dirs, 'array');

        // loop through the path directories
        foreach ($dirs as $dir) {
            // no surrounding spaces allowed!
            $dir = $this->_unifyPath(trim($dir));

            // remove trailing slash
            if (substr($dir, -1) == DS) {
                $dir = substr_replace($dir, '', -1);
            }

            // add to the top of the search dirs
            array_unshift($this->_dirs, $dir);
        }

        return $this;
    }
922707
public function getBinaryDirectoriesIterator()
    {
        if (array() !== ($directories = $this->getBinaryDirectories())) {
            return Finder::create()
                    ->files()
                    ->filter($this->getBlacklistFilter())
                    ->ignoreVCS(true)
                    ->in($directories);
        }

        return null;
    }
72939
protected function _getManifests( array $directories )
	{
		$manifests = array();

		foreach ( $directories as $directory )
		{
			if ( ( $manifest = $this->_getManifestFile( $directory ) ) !== false )
			{
				$manifests[ $directory ] = $manifest;
				continue;
			}

			$dir = new DirectoryIterator( $directory );

			foreach ( $dir as $dirinfo )
			{
				if ( $dirinfo->isDot() === false )
				{
					if ( ( $manifest = $this->_getManifestFile( $dirinfo->getPathName() ) ) !== false ) {
						$manifests[$dirinfo->getPathName()] = $manifest;
					}
				}
			}
		}

		return $manifests;
	}
700699
public function check($directories = null)
    {
        null == $directories && $directories = $this->directories;
        $return = array();
        $valid  = true;

        foreach ($directories as $path => $validationSpec) {
            $result                       = $this->checkDirectory($path, $validationSpec);
            $return['directories'][$path] = $result;
            $valid                        = $valid && $result['valid'];
        }
        $return['valid'] = $valid;

        return $return;
    }
857343
public function scanDir()
    {
        // only possible in directories
        if (!$this->isDir() || !$this->exists()) {
            return null;
        }

        $fileList = [];
        $fileNameList = scandir($this->absoluteFileName);
        foreach ($fileNameList as $fileName) {
            // do not add . and ..
            if ($fileName === "." or $fileName === "..") {
                continue;
            }
            $absoluteFileName = $this->absoluteFileName . "/" . $fileName;
            $fileList [] = new File ($absoluteFileName);
        }

        return $fileList;
    }
1183349
public function index(array $directories, array $extensions = [])
    {
        $fileSystem = new Filesystem();
        $finder = new Finder();

        // reset the change set
        $this->changes = [];
        clearstatcache();

        foreach ($directories as $directory) {
            if (!$fileSystem->exists($directory)) {
                throw new Exception('The directory '.$directory.' does not exists');
            }

            // find all files in the given directory
            $finder
                ->files()
                ->in($directory)
            ;

            // eventually filtering by file extension
            foreach ($extensions as $extension) {
                $finder->name('*.'.$extension);
            }

            // index the results
            foreach ($finder as $file) {
                $this->add($file);
            }
        }

    }
538102
function _nlist_helper($dir, $recursive, $relativeDir)
    {
        $files = $this->_list($dir, false);

        if (!$recursive || $files === false) {
            return $files;
        }

        $result = array();
        foreach ($files as $value) {
            if ($value == '.' || $value == '..') {
                if ($relativeDir == '') {
                    $result[] = $value;
                }
                continue;
            }
            if (is_array($this->_query_stat_cache($this->_realpath($dir . '/' . $value)))) {
                $temp = $this->_nlist_helper($dir . '/' . $value, true, $relativeDir . $value . '/');
                $result = array_merge($result, $temp);
            } else {
                $result[] = $relativeDir . $value;
            }
        }

        return $result;
    }