src/Console/Controllers/MessageController.php
protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused)
    {
        $promises = [];
        foreach ($messages as $category => $msgs) {
            $file = str_replace('\\', '/', "$dirName/$category.php");
            $path = dirname($file);
            $msgs = array_values(array_unique($msgs));
            $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]);
            $this->stdout("Saving messages to $coloredFileName...\n");
            $promises[] = FileHelperAsc::createDir($path, $this->filesystemMode)
                ->then(function() use ($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused) {
                    return $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused);
                });
        }
        return all($promises);
    }
protected function saveMessagesToPHP($messages, $dirName, $overwrite, $removeUnused, $sort, $markUnused)
    {
        $promises = [];
        foreach ($messages as $category => $msgs) {
            $file = str_replace('\\', '/', "$dirName/$category.php");
            $path = dirname($file);
            $msgs = array_values(array_unique($msgs));
            $coloredFileName = Console::ansiFormat($file, [Console::FG_CYAN]);
            $this->stdout("Saving messages to $coloredFileName...\n");
            $promises[] = FileHelperAsc::createDir($path, $this->filesystemMode)
                ->then(function() use ($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused) {
                    return $this->saveMessagesCategoryToPHP($msgs, $file, $overwrite, $removeUnused, $sort, $category, $markUnused);
                });
        }
        return all($promises);
    }
Writes messages into PHP files.

@param array $messages
@param string $dirName name of the directory to write to
@param bool $overwrite if existing file should be overwritten without backup
@param bool $removeUnused if obsolete translations should be removed
@param bool $sort if translations should be sorted
@param bool $markUnused if obsolete translations should be marked
@return ExtendedPromiseInterface