Scan vendor folders to find modules.
@param array &$folders Array passed by reference to be filled with modules found.
541157
private function scanVendorFolders(&$folders)
    {
        $basedir = realpath(NABU_PROVIDERS_PATH);
        if (is_dir($basedir) && ($h = opendir($basedir))) {
            while (($folder = readdir($h))) {
                if ($folder !== '.' && $folder !== '..') {
                    $this->scanModuleFolders($basedir . DIRECTORY_SEPARATOR . $folder, $folders);
                }
            }
            closedir($h);
        }
    }
784459
public function scan($project)
    {
        //@TODO: allow scan of individual files
        // First check if target is a directory
        if (!is_dir($project)) {
            $this->getConsole()->writeLine($project . ' is not a directory!');
            return $this;
        }

        $iteratorIterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($project));

        //@TODO: make ignored paths a param
        // Exclude the paths containing vendor and non-php files
        $regexIterator = new \RegexIterator($iteratorIterator, '/^(?!.*vendor.*).*\.php$/i', \RecursiveRegexIterator::GET_MATCH);

        foreach ($regexIterator as $fileMatches) {
            foreach ($fileMatches as $fileMatch) {

                $fileContent = file_get_contents($fileMatch);

                preg_match_all('/Zend\\\\[a-zA-Z0-9]*/', (string) $fileContent, $matches, PREG_PATTERN_ORDER);

                foreach ($matches as $submatches) {
                    foreach ($submatches as $match) {
                        $zendComponent = strtolower(str_replace('\\', '-', $match));
                        $componentParts = explode('-', $zendComponent);

                        if ($componentParts[0] !== '' && $componentParts[1] !== '') {
                            $this->components[$zendComponent] = true;
                        }
                    }
                }
            }
        }

        ksort($this->components);

        return $this;
    }
1317321
public void uncheckFolders(Collection<String> folders) {

        for (String folder : folders) {
            CmsLazyTreeItem item = m_itemsByPath.get(folder);
            if ((item != null) && (item.getCheckBox() != null)) {
                item.getCheckBox().setChecked(false);
            }
        }
    }
1320575
private void addFoldersToSearchIn(final List<String> folders) {

        if (null == folders) {
            return;
        }

        for (String folder : folders) {
            if (!CmsResource.isFolder(folder)) {
                folder += "/";
            }

            m_foldersToSearchIn.add(folder);
        }
    }
784280
public function SetImportDirs( $dirs ){
		Less_Parser::$options['import_dirs'] = array();

		foreach($dirs as $path => $uri_root){

			$path = self::WinPath($path);
			if( !empty($path) ){
				$path = rtrim($path,'/').'/';
			}

			if ( !is_callable($uri_root) ){
				$uri_root = self::WinPath($uri_root);
				if( !empty($uri_root) ){
					$uri_root = rtrim($uri_root,'/').'/';
				}
			}

			Less_Parser::$options['import_dirs'][$path] = $uri_root;
		}
	}
1059645
private function scanFolders(string $dir, bool $recursive): array
    {
        $files = [];

        // $dir comes from the database. The actual folder may not exist.
        if (is_dir($dir)) {
            foreach (scandir($dir, SCANDIR_SORT_NONE) as $path) {
                if (is_dir($dir . $path)) {
                    // What if there are user-defined subfolders “thumbs” or “watermarks”?
                    if ($path !== '.' && $path !== '..' && $path !== 'thumbs' && $path !== 'watermark' && $recursive) {
                        foreach ($this->scanFolders($dir . $path . '/', $recursive) as $subpath) {
                            $files[] = $path . '/' . $subpath;
                        }
                    }
                } else {
                    $files[] = $path;
                }
            }
        }

        return $files;
    }
233864
protected function parseExtraFolders()
    {
        foreach ($this->extraFolders as $folder) {
            $finder = new Finder();
            if (is_dir($folder)) {
                $bundleFolders = $finder->directories()->depth(0)->in($folder);
                foreach ($bundleFolders as $bundleFolder) {
                    $bundleName = basename($bundleFolder);
                    $this->addBundle($bundleName, (string)$bundleFolder);
                }
            }
        }
    }
841043
private function scan(Translations $translations)
    {
        foreach ($this->iterator as $each) {
            foreach ($each as $file) {
                if ($file === null || !$file->isFile()) {
                    continue;
                }

                $target = $file->getPathname();

                if (($fn = $this->getFunctionName('addFrom', $target, 'File'))) {
                    $translations->$fn($target);
                }
            }
        }
    }
881659
public void scan(final String[] packages) {
        LOGGER.info("Scanning packages {}:", ArrayUtils.toString(packages));
        for (final String pkg : packages) {
            try {
                final String pkgFile = pkg.replace('.', '/');
                final Enumeration<URL> urls = getRootClassloader().getResources(pkgFile);
                while (urls.hasMoreElements()) {
                    final URL url = urls.nextElement();
                    try {
                        final URI uri = getURI(url);
                        LOGGER.debug("Scanning {}", uri);
                        scan(uri, pkgFile);
                    } catch (final URISyntaxException e) {
                        LOGGER.debug("URL {} cannot be converted to a URI", url, e);
                    }
                }
            } catch (final IOException ex) {
                throw new RuntimeException("The resources for the package" + pkg + ", could not be obtained",
                        ex);
            }
        }
        LOGGER.info(
                "Found {} matching classes and {} matching files",
                matchingClasses.size(),
                matchingFiles.size());
    }
274823
protected function scanArray(array $paths)
    {
        $files         = [];
        $detections    = [];

        foreach ($paths as $path) {
            $result     = $this->scanSingle($path, $this->options);
            $paths      = array_merge($paths, $result->getPaths());
            $files      = array_merge($files, $result->getFiles());
            $detections = array_merge($detections, $result->getDetections());
        }

        return new ScanResult($paths, $files, $detections);
    }
156500
public function locateFileInFolder($filename, array $folders)
    {
        $list = [];
        foreach ($folders as $folder) {
            $list += $this->detectInFolder($folder, $filename);
        }
        return $list;
    }
470658
public function containsModules(array $modules)
    {
        foreach ($modules as $module) {
            if (!$this->modules->contains($module)) {
                return false;
            }
        }

        return true;
    }
1360206
public function scanModules() {
        $modules = RtCache::get('loader@modules');
        if (!$modules) {
            $modules = [];
            if (is_dir(MODULE_ROOT)) {
                $it = new \DirectoryIterator (MODULE_ROOT);
                foreach ($it as $dir) {
                    if ($dir->isDot()) {
                        continue;
                    }
                    if ($dir->isDir()) {
                        $dirname = $dir->getFilename();
                        $boot    = MODULE_ROOT . $dirname . '/bootstrap.php';
                        if (is_file($boot)) {
                            $modules[ $dirname ] = $boot;
                        }
                    }
                }
            }
            RtCache::add('loader@modules', $modules);
        }

        return $modules;
    }
121728
public function resolveDirectoriesWithFnmatch(array $directories): array
    {
        $absoluteDirectories = [];
        foreach ($directories as $directory) {
            if (Strings::contains($directory, '*')) { // is fnmatch for directories
                $absoluteDirectories = array_merge($absoluteDirectories, glob($directory, GLOB_ONLYDIR));
            } else { // is classic directory
                $this->ensureDirectoryExists($directory);
                $absoluteDirectories[] = $directory;
            }
        }

        return $absoluteDirectories;
    }
510828
protected function gatherLoadedPackagesHandles($packages)
    {
        $packages = (array) $packages;
        if (!$packages) {
            $plugins = $this->container->getPlugins();
            foreach ($plugins as $plugin) {
                $path = (new ReflectionClass($plugin))->getFileName();
                preg_match('/vendor\/([^\/]+)\/([^\/]+)/', $path, $handle);
                if (count($handle) !== 3) {
                    continue;
                }

                $packages[] = $handle[1].'/'.$handle[2];
            }
        }

        return $packages;
    }
563316
def get_plugin_modules(folders, package='plugins',
                       parentpackage='linkcheck.dummy'):
    """"""
    for folder in folders:
        for module in loader.get_folder_modules(folder, parentpackage):
            yield module
    for module in loader.get_package_modules(package):
        yield module
676506
protected function readPackageFolder(string $folder): array
    {
        $packages = [];
        foreach (scandir($folder) as $path) {
            if ($path === '.' || $path === '..') {
                continue;
            }

            $fullPath = $this->pathHelper->join($folder, $path);

            if (!is_dir($fullPath)) {
                continue;
            }

            $composerJson = $this->composerParser->parse(
                $this->pathHelper->realize($this->pathHelper->join($fullPath, 'composer.json'))
            );

            $packages[$fullPath] = $composerJson;
        }

        return $packages;
    }