src/I18n/PhpMessageSource.php
protected function findAllCategories()
    {
        if (isset($this->_categories)) {
            return resolve($this->_categories);
        }
        $categoryMap = is_array($this->fileMap) ? array_flip($this->fileMap) : [];
        $baseDirPath = Reaction::getAlias($this->basePath);
        //Use resolve()->then() to convert PromiseInterface to ExtendedPromiseInterface
        return resolve(true)
            ->then(function() use ($baseDirPath, $categoryMap) {
                $dir = Reaction\Helpers\FileHelperAsc::dir($baseDirPath);
                return $dir->lsRecursive()
                    ->then(function($results) use ($baseDirPath, $categoryMap) {
                        $categories = [];
                        foreach ($results as $result) {
                            if (!is_object($result) || !$result instanceof FileInterface || substr($result->getPath(), -4) !== '.php') {
                                continue;
                            }
                            //Remove base path part
                            $filePath = substr($result->getPath(), mb_strlen($baseDirPath) + 1);
                            //Remove language part
                            if (($langSepPos = strpos($filePath, DIRECTORY_SEPARATOR)) !== false) {
                                $filePath = substr($filePath, $langSepPos + 1);
                            }
                            //Search category in file map
                            if (isset($categoryMap[$filePath])) {
                                $categories[] = $categoryMap[$filePath];
                                continue;
                            } else {
                                //Remove .php extension
                                $filePath = substr($filePath, 0, -4);
                            }
                            //Add possible category with another slashes
                            if (strpos($filePath, DIRECTORY_SEPARATOR) !== false) {
                                $categories[] = str_replace(DIRECTORY_SEPARATOR, '\\', $filePath);
                            }
                            $categories[] = $filePath;
                        }
                        $this->_categories = array_unique($categories);
                        sort($this->_categories);
                        return $this->_categories;
                    });
            });

    }
protected function findAllCategories()
    {
        if (isset($this->_categories)) {
            return resolve($this->_categories);
        }
        $categoryMap = is_array($this->fileMap) ? array_flip($this->fileMap) : [];
        $baseDirPath = Reaction::getAlias($this->basePath);
        //Use resolve()->then() to convert PromiseInterface to ExtendedPromiseInterface
        return resolve(true)
            ->then(function() use ($baseDirPath, $categoryMap) {
                $dir = Reaction\Helpers\FileHelperAsc::dir($baseDirPath);
                return $dir->lsRecursive()
                    ->then(function($results) use ($baseDirPath, $categoryMap) {
                        $categories = [];
                        foreach ($results as $result) {
                            if (!is_object($result) || !$result instanceof FileInterface || substr($result->getPath(), -4) !== '.php') {
                                continue;
                            }
                            //Remove base path part
                            $filePath = substr($result->getPath(), mb_strlen($baseDirPath) + 1);
                            //Remove language part
                            if (($langSepPos = strpos($filePath, DIRECTORY_SEPARATOR)) !== false) {
                                $filePath = substr($filePath, $langSepPos + 1);
                            }
                            //Search category in file map
                            if (isset($categoryMap[$filePath])) {
                                $categories[] = $categoryMap[$filePath];
                                continue;
                            } else {
                                //Remove .php extension
                                $filePath = substr($filePath, 0, -4);
                            }
                            //Add possible category with another slashes
                            if (strpos($filePath, DIRECTORY_SEPARATOR) !== false) {
                                $categories[] = str_replace(DIRECTORY_SEPARATOR, '\\', $filePath);
                            }
                            $categories[] = $filePath;
                        }
                        $this->_categories = array_unique($categories);
                        sort($this->_categories);
                        return $this->_categories;
                    });
            });

    }
Find all categories used in message source
@return ExtendedPromiseInterface