mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 21:38:22 +01:00
make OutputFormatters specific for DumpRectorsCommand
This commit is contained in:
parent
bfff23fbb2
commit
62fb154906
@ -20,7 +20,9 @@ $configFiles = array_filter($configFiles);
|
||||
|
||||
// 3. Build DI container
|
||||
|
||||
$rectorKernel = new RectorKernel('prod', InputDetector::isDebug());
|
||||
// to override the configs without clearing cache
|
||||
$environment = 'prod' . random_int(1, 10000000);
|
||||
$rectorKernel = new RectorKernel($environment, InputDetector::isDebug());
|
||||
if ($configFiles) {
|
||||
$rectorKernel->setConfigs($configFiles);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ namespace Rector\ContributorTools\Command;
|
||||
|
||||
use Rector\Console\Command\AbstractCommand;
|
||||
use Rector\Console\Shell;
|
||||
use Rector\ContributorTools\Contract\OutputFormatterInterface;
|
||||
use Rector\ContributorTools\Contract\OutputFormatter\DumpRectorsOutputFormatterInterface;
|
||||
use Rector\ContributorTools\Finder\RectorsFinder;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -19,19 +19,19 @@ final class DumpRectorsCommand extends AbstractCommand
|
||||
private $rectorsFinder;
|
||||
|
||||
/**
|
||||
* @var OutputFormatterInterface[]
|
||||
* @var DumpRectorsOutputFormatterInterface[]
|
||||
*/
|
||||
private $outputFormatters = [];
|
||||
private $dumpRectorsOutputFormatterInterfaces = [];
|
||||
|
||||
/**
|
||||
* @param OutputFormatterInterface[] $outputFormatters
|
||||
* @param DumpRectorsOutputFormatterInterface[] $dumpRectorsOutputFormatterInterfaces
|
||||
*/
|
||||
public function __construct(RectorsFinder $rectorsFinder, array $outputFormatters)
|
||||
public function __construct(RectorsFinder $rectorsFinder, array $dumpRectorsOutputFormatterInterfaces)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->rectorsFinder = $rectorsFinder;
|
||||
$this->outputFormatters = $outputFormatters;
|
||||
$this->dumpRectorsOutputFormatterInterfaces = $dumpRectorsOutputFormatterInterfaces;
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
@ -52,7 +52,7 @@ final class DumpRectorsCommand extends AbstractCommand
|
||||
$packageRectors = $this->rectorsFinder->findInDirectory(__DIR__ . '/../../../../packages');
|
||||
$generalRectors = $this->rectorsFinder->findInDirectory(__DIR__ . '/../../../../src');
|
||||
|
||||
foreach ($this->outputFormatters as $outputFormatter) {
|
||||
foreach ($this->dumpRectorsOutputFormatterInterfaces as $outputFormatter) {
|
||||
if ($outputFormatter->getName() !== $input->getOption('output-format')) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\ContributorTools\Contract;
|
||||
namespace Rector\ContributorTools\Contract\OutputFormatter;
|
||||
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
|
||||
interface OutputFormatterInterface
|
||||
interface DumpRectorsOutputFormatterInterface
|
||||
{
|
||||
public function getName(): string;
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\ContributorTools\OutputFormatter;
|
||||
namespace Rector\ContributorTools\OutputFormatter\DumpRectors;
|
||||
|
||||
use Nette\Utils\DateTime;
|
||||
use Nette\Utils\Json;
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\ContributorTools\Contract\OutputFormatterInterface;
|
||||
use Rector\ContributorTools\Contract\OutputFormatter\DumpRectorsOutputFormatterInterface;
|
||||
use Rector\ContributorTools\RectorMetadataResolver;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Rector\RectorDefinition\RectorDefinition;
|
||||
|
||||
final class JsonOutputFormatter implements OutputFormatterInterface
|
||||
final class JsonDumpRectorsOutputFormatter implements DumpRectorsOutputFormatterInterface
|
||||
{
|
||||
/**
|
||||
* @var RectorMetadataResolver
|
@ -1,18 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\ContributorTools\OutputFormatter;
|
||||
namespace Rector\ContributorTools\OutputFormatter\DumpRectors;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use Rector\ConsoleDiffer\MarkdownDifferAndFormatter;
|
||||
use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\Contract\RectorDefinition\CodeSampleInterface;
|
||||
use Rector\ContributorTools\Contract\OutputFormatterInterface;
|
||||
use Rector\ContributorTools\Contract\OutputFormatter\DumpRectorsOutputFormatterInterface;
|
||||
use Rector\ContributorTools\RectorMetadataResolver;
|
||||
use Rector\RectorDefinition\ConfiguredCodeSample;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
final class MarkdownOutputFormatter implements OutputFormatterInterface
|
||||
final class MarkdownDumpRectorsOutputFormatter implements DumpRectorsOutputFormatterInterface
|
||||
{
|
||||
/**
|
||||
* @var SymfonyStyle
|
Loading…
x
Reference in New Issue
Block a user