Recursively finds all files with the .php extension in the provided
$paths and returns list as array.
@param  array $paths Paths in which to look for .php files.
@return FileCollection
195278
public function getPhpFiles(array $paths): FileCollection
    {
        $this->files = new FileCollection;
        foreach ($paths as $path) {
            $this->getPhpFilesFromPath($path);
        }

        return $this->files;
    }
1187297
public static function join($paths)
    {
        if (!is_array($paths)) {
            $paths = func_get_args();
        }

        Assert::allString($paths, 'The paths must be strings. Got: %s');

        $finalPath = null;
        $wasScheme = false;

        foreach ($paths as $path) {
            $path = (string) $path;

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

            if (null === $finalPath) {
                // For first part we keep slashes, like '/top', 'C:\' or 'phar://'
                $finalPath = $path;
                $wasScheme = (strpos($path, '://') !== false);
                continue;
            }

            // Only add slash if previous part didn't end with '/' or '\'
            if (!in_array(substr($finalPath, -1), array('/', '\\'))) {
                $finalPath .= '/';
            }

            // If first part included a scheme like 'phar://' we allow current part to start with '/', otherwise trim
            $finalPath .= $wasScheme ? $path : ltrim($path, '/');
            $wasScheme = false;
        }

        if (null === $finalPath) {
            return '';
        }

        return self::canonicalize($finalPath);
    }
1267680
public function getMigrationFiles($paths)
    {
        return Collection::make($paths)->flatMap(function ($path) {
            return Str::endsWith($path, '.php') ? [$path] : $this->files->glob($path.'/*_*.php');
        })->filter()->sortBy(function ($file) {
            return $this->getMigrationName($file);
        })->values()->keyBy(function ($file) {
            return $this->getMigrationName($file);
        })->all();
    }
30474
private static function getPaths(iterable $paths): iterable
    {
        // The idea is to normalize paths. It means build all intermediate paths.
        // e.g. if only `a.b.c` path it given it will be normalized to `a`, `a.b` and `a.b.c`.
        // Path depths store depth of each path (e.g. 0 for root, 1 for `a`, 2 for `a.b` and etc).
        // It is needed for yielding them in correct order (from top level to bottom).
        $normalizedPaths = [];
        $pathsDepths     = [];
        foreach ($paths as $path) {
            assert(is_array($path) || $path instanceof Traversable);
            $parentDepth = 0;
            $tmpPath     = static::ROOT_PATH;
            foreach ($path as $pathPiece) {
                assert(is_string($pathPiece));
                $parent                    = $tmpPath;
                $tmpPath                   = empty($tmpPath) === true ?
                    $pathPiece : $tmpPath . static::PATH_SEPARATOR . $pathPiece;
                $normalizedPaths[$tmpPath] = [$parent, $pathPiece];
                $pathsDepths[$parent]      = $parentDepth++;
            }
        }

        // Here we collect paths in form of parent => [list of children]
        // e.g. '' => ['a', 'c', 'b'], 'b' => ['bb', 'aa'] and etc
        $parentWithChildren = [];
        foreach ($normalizedPaths as $path => list ($parent, $childPath)) {
            $parentWithChildren[$parent][] = $childPath;
        }

        // And finally sort by path depth and yield parent with its children. Top level paths first then deeper ones.
        asort($pathsDepths, SORT_NUMERIC);
        foreach ($pathsDepths as $parent => $depth) {
            assert($depth !== null); // suppress unused
            $childPaths = $parentWithChildren[$parent];
            yield [$parent, $childPaths];
        }
    }
567176
private static function getPathFiles(array $path): array
    {
        // load external files
        $result = [];
        $pathFinder = Finder::findFiles('*')->in($path);
        foreach ($pathFinder as $file) {
            $result[$file->getRealPath()] = $file->getBaseName();
        }
        return $result;
    }
496299
public function find($paths = null)
    {
        if ($paths === null) $paths = $this->paths;

        // iterator
        $iterator = $this->getIterator();

        // search in target paths
        foreach ((array)$paths as $path) {
            $this->searchInPath($iterator, $path);
        }

        // clear
        $this->clear();

        return $iterator;
    }
850920
public function files(String $path, String $extension = NULL) : Array
    {
        $list = ftp_nlist($this->connect, $path);

        if( ! empty($list) ) foreach( $list as $file )
        {
            if( $file !== '.' && $file !== '..' )
            {
                if( ! empty($extension) && $extension !== 'dir' )
                {
                    if( Filesystem::getExtension($file) === $extension )
                    {
                        $files[] = $file;
                    }
                }
                else
                {
                    if( $extension === 'dir' )
                    {
                        $extens = Filesystem::getExtension($file);

                        if( empty($extens) )
                        {
                            $files[] = $file;
                        }
                    }
                    else
                    {
                        $files[] = $file;
                    }
                }
            }
        }

        if( ! empty($files) )
        {
            return $files;
        }
        else
        {
            return [];
        }
    }
244268
private function getFiles($path)
    {
        $files = [];

        if (false !== $pos = strpos($path, '*')) {
            list($before, $after) = explode('*', $path, 2);
            $input = $this->fileLocator->locate($before).'*'.$after;

            if (false !== $paths = glob($input)) {
                foreach ($paths as $path) {
                    $files[] = $path;
                }
            }
        } else {
            $files = [$this->fileLocator->locate($path)];
        }

        return $files;
    }
349069
public function getDeployFiles($paths)
    {
        return Collection::make($paths)->flatMap(function ($path) {
            return $this->files->glob($path.'/*.php');
        })->filter()->sortBy(function ($file) {
                return $this->getDeployName($file);
            })->values()->keyBy(function ($file) {
                return $this->getDeployName($file);
            })->all();
    }
98105
public function findPhp($path)
    {
        $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
        $phpFiles = new RegexIterator($allFiles, '/\.php$/');
        $files = array();
        foreach ($phpFiles as $phpFile) {
            $filename = $phpFile->getRealpath();
            $content = file_get_contents($filename);
            $files[] = new File($filename, $content);
        }

        return $files;
    }
553614
public function load(array $paths)
    {
        $finder = new Finder();
        $finder->in($paths);
        $finder->name('*Fixture.php');

        foreach ($finder as $file) {
            $declaredClasses = get_declared_classes();
            require_once $file;
            $declaredClassesDiff = array_diff(get_declared_classes(), $declaredClasses);
            $fixtureClass = array_pop($declaredClassesDiff);

            if (!$fixtureClass) {
                throw new \InvalidArgumentException(sprintf(
                    'Could not determine class from included file "%s". Class detection will only work once per request.',
                    $file
                ));
            }

            $refl = new \ReflectionClass($fixtureClass);

            if ($refl->isAbstract()) {
                continue;
            }

            if (false === $refl->isSubclassOf(DocumentFixtureInterface::class)) {
                continue;
            }

            $fixture = new $fixtureClass();

            if ($fixture instanceof ContainerAwareInterface) {
                $fixture->setContainer($this->container);
            }

            $fixtures[] = $fixture;
        }

        usort($fixtures, function(DocumentFixtureInterface $fixture1, DocumentFixtureInterface $fixture2) {
            return $fixture1->getOrder() > $fixture2->getOrder();
        });

        return $fixtures;
    }
782076
public static function loadConfig($paths)
    {
        $apaths = explode(';', $paths);
        foreach ($apaths as $path) {
            if (is_file($p = realpath($path))) {
                $ext = strtolower(pathinfo($p, PATHINFO_EXTENSION));
                if ($ext === 'conf') {
                    return Daemon::$config->loadFile($p);
                } else {
                    Daemon::log('Config file \'' . $p . '\' has unsupported file extension.');
                    return false;
                }
            }
        }
        Daemon::log('Config file not found in \'' . $paths . '\'.');
        return false;
    }
1285713
public static function mergePreflightDir(array $paths): array
    {
        if (defined('PREFLIGHT_DIR')) {
            $dir = constant('PREFLIGHT_DIR');
            $path = trailingslashit($dir) . 'preflight.toml';

            $paths[] = normalize_path($path);
        }

        return $paths;
    }
537717
public function findAll(array $locations = [])
    {
        if (empty($locations)) {
            $locations = $this->lookupPaths;
        }

        $finder = new Finder;
        $finder->directories()->depth(0)->sortByName()->in($locations);

        return iterator_to_array($finder, true);
    }
491591
protected function mapPathsWithType(array $paths, string $type): array
    {
        return \array_map(function ($item) use ($type) {
            return [
                'path' => $item,
                'type' => $type,
            ];
        }, \array_unique($paths));
    }
252410
public function getMultipleChildren(array $paths)
    {
        $objs = $this->caldavBackend->getMultipleCalendarObjects($this->calendarInfo['id'], $paths);
        $children = [];
        foreach ($objs as $obj) {
            $obj['acl'] = $this->getChildACL();
            $children[] = new CalendarObject($this->caldavBackend, $this->calendarInfo, $obj);
        }

        return $children;
    }
625379
public function listFacets($paths) {
		$request = new CPS_ListFacetsRequest($paths);
		$this->_lastResponse = $this->_connection->sendRequest($request);
		return $this->_lastResponse->getFacets();
	}