Get all languages and their's paths.

@param array $paths

@return array
15869
protected function getLanguages(array $paths = [])
    {
        // Get language path
        $dir_lang = $this->getLangPath();

        // Only use the default locale
        if ($this->config('default_locale_only')) {
            return [
                $this->default_locale => "{$dir_lang}/{$this->default_locale}",
            ];
        }

        // Get all language paths
        foreach (glob("{$dir_lang}/*", GLOB_ONLYDIR) as $path) {
            $paths[basename($path)] = $path;
        }

        return $paths;
    }
437947
protected function extractTranslationFromFile($path)
    {
        $result = [];
        $string = file_get_contents($path);

        foreach (array_flatten($this->config('trans_methods', [])) as $method) {
            preg_match_all($method, $string, $matches);

            foreach ($matches[1] as $k => $v) {
                if (strpos($v, '$') !== false) {
                    unset($matches[1][$k]);
                }
                if (strpos($v, '::') !== false) {
                    unset($matches[1][$k]);
                }
            }

            $result = array_merge($result, array_flip($matches[1]));
        }

        return $result;
    }
1151413
public static function getComposerFiles($paths)
    {
        settype($paths, 'array');

        $composers = array();

        foreach ($paths as $path) {

            $dirs = new \DirectoryIterator($path);

            foreach ($dirs as $dir) {

                if ($dir->isDot() || $dir->isFile()) {
                    continue;
                }

                $composer_file = $dir->getPathName().'/composer.json';

                if (is_readable($composer_file)) {
                    $composers[] = $composer_file;
                }
            }
        }

        return $composers;
    }
128282
private static function retrieveFilesFromPaths(array $paths): iterable
    {
        if ([] === $paths) {
            return [];
        }

        $pathsToSearch = [];
        $filesToAppend = [];

        foreach ($paths as $path) {
            if (false === file_exists($path)) {
                throw new RuntimeException(
                    sprintf(
                        'Could not find the file "%s".',
                        $path
                    )
                );
            }

            if (is_dir($path)) {
                $pathsToSearch[] = $path;
            } else {
                $filesToAppend[] = $path;
            }
        }

        $finder = new Finder();

        $finder->files()
            ->in($pathsToSearch)
            ->append($filesToAppend)
            ->filter(static function (SplFileInfo $fileInfo): ?bool {
                if ($fileInfo->isLink()) {
                    return false;
                }

                return null;
            })
            ->sortByName()
        ;

        return $finder;
    }
1247236
public function getMigrationFiles($path)
    {
        $files = Helpers::rGlob($path.'/*_*.php');

        if ($files === false) {
            return [];
        }

        $files = array_map(function ($file) {
            return str_replace('.php', '', basename($file));

        }, $files);

        sort($files);

        return $files;
    }
271114
protected static function scanAvailableModules($paths)
    {
        if (!is_array($paths)) {
            $paths = [$paths];
        }
        $modules = [];
        foreach ($paths as $path) {
            $path = Yii::getAlias($path);
            if (is_dir($path) && (($handle = opendir($path)) !== false)) {
                while (($file = readdir($handle)) !== false) {
                    if (in_array($file, ['.', '..']) || !is_dir($currentPath = $path . DIRECTORY_SEPARATOR . $file)) {
                        continue;
                    }
                    // 是否有wechat.yml安装配置文件
                    $settingFile = $currentPath . DIRECTORY_SEPARATOR . 'wechat.yml';
                    if (file_exists($settingFile)) {
                        $class = Yii::$app->getModule('wechat')->moduleModelClass;
                        $model = new $class;
                        $model->setAttributes(Yaml::parse(file_get_contents($settingFile)));
                        if ($model->id == $file && $model->validate()) { // 模块名必须等于目录名并且验证模块正确性
                            $modules[$model->id] = $model;
                        }
                    }
                }
            }
        }
        return $modules;
    }
303611
public function getTranslations($lang)
    {
        $path = $this->getTranslationPathBaseDirectory('lang', $lang);

        if (!is_readable($path)) {
            return array();
        }

        $data = file_get_contents($path);
        $translations = json_decode($data, true);

        return $translations;
    }
386437
public function findTranslationsFilesByPaths(string $path) : Finder
    {
        $finder = new Finder();
        $finder
            ->files()
            ->in($path)
            ->name('*.php');

        return $finder;
    }
1185469
public function retrieveAvailableLocales($path = '/../Resources/translations/')
    {
        $locales = array();
        $data = $this->configHandler->getParameter('locales');

        foreach ($data as $locale) {
            $locales[$locale] = $locale;
        }

        return $locales;
    }
748956
public function lsDirs(string $path = '') : array
    {
        return array_filter(
            $this->ls($path),
            function(File $file) {
                return $file->isDir();
            }
        );
    }
37530
public function getImportPaths($path = null)
    {
        if ($path === null) {
            return $this->importPaths;
        }

        return isset($this->importPaths[$path])
            ? $this->importPaths[$path]
            : [];
    }
974991
public function getI18nPaths()
	{
		$paths = array();

		foreach ( $this->_manifests as $basePath => $manifest )
		{
			if ( isset( $manifest['i18n'] ) )
			{
				foreach( $manifest['i18n'] as $domain => $location ) {
					$paths[$domain][] = $basePath . DIRECTORY_SEPARATOR . $location;
				}
			}
		}

		return $paths;
	}
195278
public function getPhpFiles(array $paths): FileCollection
    {
        $this->files = new FileCollection;
        foreach ($paths as $path) {
            $this->getPhpFilesFromPath($path);
        }

        return $this->files;
    }
641364
private static function getLangs() 
  {
    if (self::$langs === null) {

      // Load available languages from `resources/lang`.
      self::$langs = [];
      $langPath = base_path() . '/resources/lang/';
      if (!is_dir($langPath)) {
        error_log("The directory /resources/lang/' doesn't exists.");
        throw new PathNotFoundException();
      }
      $iter = new \FilesystemIterator($langPath);
      foreach ($iter as $fileInfo) {
        if ($fileInfo->isDir()) {
          self::$langs[] = $fileInfo->getFilename();
        }
      } // foreach

    } // if

    return self::$langs;
  }
531927
private function determineMostCommonBaseAppPath($paths)
    {
        $paths = array_values($paths);

        $options = [];
        $options[] = Path::getLongestCommonBasePath($paths);
        if (isset($paths[1])) {
            $options[] = Path::getLongestCommonBasePath([$paths[0], $paths[1]]);
        }
        if (isset($paths[2])) {
            $options[] = Path::getLongestCommonBasePath([$paths[1], $paths[2]]);
            $options[] = Path::getLongestCommonBasePath([$paths[0], $paths[2]]);
        }
        rsort($options);

        return reset($options);
    }
144282
protected function getPathAsArray($path)
    {
        $path = str_replace('\/', '@@@', $path);
        $path = rtrim($path, "/");
        $segments = explode('/', $path);
        return array_map(function($item) {
            return str_replace('@@@', '/', $item);
        }, $segments);
    }
73431
protected function getPhpFiles($path)
    {
        if (is_dir($path)) {
            return new RegexIterator(
                new RecursiveIteratorIterator(
                    new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
                    RecursiveIteratorIterator::SELF_FIRST,
                    RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
                ),
                '/^.+\.php$/i',
                RecursiveRegexIterator::GET_MATCH
            );
        }
        else {
            return [];
        }
    }