|
@@ -36,6 +36,14 @@ final class DocumentationCommand extends Command
|
|
/** @var string */
|
|
/** @var string */
|
|
protected static $defaultName = 'documentation';
|
|
protected static $defaultName = 'documentation';
|
|
|
|
|
|
|
|
+ private Filesystem $filesystem;
|
|
|
|
+
|
|
|
|
+ public function __construct(Filesystem $filesystem)
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ $this->filesystem = $filesystem;
|
|
|
|
+ }
|
|
|
|
+
|
|
protected function configure(): void
|
|
protected function configure(): void
|
|
{
|
|
{
|
|
$this
|
|
$this
|
|
@@ -46,7 +54,6 @@ final class DocumentationCommand extends Command
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
{
|
|
{
|
|
- $filesystem = new Filesystem();
|
|
|
|
$locator = new DocumentationLocator();
|
|
$locator = new DocumentationLocator();
|
|
|
|
|
|
$fixerFactory = new FixerFactory();
|
|
$fixerFactory = new FixerFactory();
|
|
@@ -66,7 +73,7 @@ final class DocumentationCommand extends Command
|
|
|
|
|
|
foreach ($fixers as $fixer) {
|
|
foreach ($fixers as $fixer) {
|
|
$docForFixerRelativePaths[] = $locator->getFixerDocumentationFileRelativePath($fixer);
|
|
$docForFixerRelativePaths[] = $locator->getFixerDocumentationFileRelativePath($fixer);
|
|
- $filesystem->dumpFile(
|
|
|
|
|
|
+ $this->filesystem->dumpFile(
|
|
$locator->getFixerDocumentationFilePath($fixer),
|
|
$locator->getFixerDocumentationFilePath($fixer),
|
|
$fixerDocumentGenerator->generateFixerDocumentation($fixer)
|
|
$fixerDocumentGenerator->generateFixerDocumentation($fixer)
|
|
);
|
|
);
|
|
@@ -78,12 +85,12 @@ final class DocumentationCommand extends Command
|
|
->in($locator->getFixersDocumentationDirectoryPath())
|
|
->in($locator->getFixersDocumentationDirectoryPath())
|
|
->notPath($docForFixerRelativePaths) as $file
|
|
->notPath($docForFixerRelativePaths) as $file
|
|
) {
|
|
) {
|
|
- $filesystem->remove($file->getPathname());
|
|
|
|
|
|
+ $this->filesystem->remove($file->getPathname());
|
|
}
|
|
}
|
|
|
|
|
|
// Fixer doc. index
|
|
// Fixer doc. index
|
|
|
|
|
|
- $filesystem->dumpFile(
|
|
|
|
|
|
+ $this->filesystem->dumpFile(
|
|
$locator->getFixersDocumentationIndexFilePath(),
|
|
$locator->getFixersDocumentationIndexFilePath(),
|
|
$fixerDocumentGenerator->generateFixersDocumentationIndex($fixers)
|
|
$fixerDocumentGenerator->generateFixersDocumentationIndex($fixers)
|
|
);
|
|
);
|
|
@@ -92,7 +99,7 @@ final class DocumentationCommand extends Command
|
|
|
|
|
|
/** @var SplFileInfo $file */
|
|
/** @var SplFileInfo $file */
|
|
foreach ((new Finder())->files()->in($locator->getRuleSetsDocumentationDirectoryPath()) as $file) {
|
|
foreach ((new Finder())->files()->in($locator->getRuleSetsDocumentationDirectoryPath()) as $file) {
|
|
- $filesystem->remove($file->getPathname());
|
|
|
|
|
|
+ $this->filesystem->remove($file->getPathname());
|
|
}
|
|
}
|
|
|
|
|
|
$paths = [];
|
|
$paths = [];
|
|
@@ -100,12 +107,12 @@ final class DocumentationCommand extends Command
|
|
foreach ($setDefinitions as $name => $definition) {
|
|
foreach ($setDefinitions as $name => $definition) {
|
|
$path = $locator->getRuleSetsDocumentationFilePath($name);
|
|
$path = $locator->getRuleSetsDocumentationFilePath($name);
|
|
$paths[$path] = $definition;
|
|
$paths[$path] = $definition;
|
|
- $filesystem->dumpFile($path, $ruleSetDocumentationGenerator->generateRuleSetsDocumentation($definition, $fixers));
|
|
|
|
|
|
+ $this->filesystem->dumpFile($path, $ruleSetDocumentationGenerator->generateRuleSetsDocumentation($definition, $fixers));
|
|
}
|
|
}
|
|
|
|
|
|
// RuleSet doc. index
|
|
// RuleSet doc. index
|
|
|
|
|
|
- $filesystem->dumpFile(
|
|
|
|
|
|
+ $this->filesystem->dumpFile(
|
|
$locator->getRuleSetsDocumentationIndexFilePath(),
|
|
$locator->getRuleSetsDocumentationIndexFilePath(),
|
|
$ruleSetDocumentationGenerator->generateRuleSetsDocumentationIndex($paths)
|
|
$ruleSetDocumentationGenerator->generateRuleSetsDocumentationIndex($paths)
|
|
);
|
|
);
|