diff --git a/config/services.yaml b/config/services.yaml index 3193af005278..fa2761468881 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -23,7 +23,6 @@ services: alias: 'Rector\Console\Application' Symfony\Component\Console\Descriptor\TextDescriptor: null - Symfony\Component\Process\PhpExecutableFinder: null # PhpParser - Parser PhpParser\ParserFactory: null diff --git a/src/Console/Command/ProcessCommand.php b/src/Console/Command/ProcessCommand.php index 711eb9360f27..384828af296b 100644 --- a/src/Console/Command/ProcessCommand.php +++ b/src/Console/Command/ProcessCommand.php @@ -15,7 +15,6 @@ use Rector\Extension\ReportingExtensionRunner; use Rector\FileSystem\FilesFinder; use Rector\Guard\RectorGuard; -use Rector\Linter\Linter; use Rector\PhpParser\NodeTraverser\RectorNodeTraverser; use Rector\Stubs\StubLoader; use Symfony\Component\Console\Input\InputArgument; @@ -86,11 +85,6 @@ final class ProcessCommand extends AbstractCommand */ private $paths = []; - /** - * @var Linter - */ - private $linter; - /** * @param string[] $paths * @param string[] $fileExtensions @@ -106,7 +100,6 @@ public function __construct( ReportingExtensionRunner $reportingExtensionRunner, RectorNodeTraverser $rectorNodeTraverser, StubLoader $stubLoader, - Linter $linter, array $paths, array $fileExtensions ) { @@ -122,7 +115,6 @@ public function __construct( $this->rectorNodeTraverser = $rectorNodeTraverser; $this->stubLoader = $stubLoader; $this->paths = $paths; - $this->linter = $linter; parent::__construct(); } @@ -201,6 +193,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->configuration->setAreAnyPhpRectorsLoaded((bool) $this->rectorNodeTraverser->getPhpRectorCount()); $this->rectorGuard->ensureSomeRectorsAreRegistered(); + $this->rectorGuard->ensureGetNodeTypesAreNodes(); $this->stubLoader->loadStubs(); $source = $this->resolvesSourcePaths($input); @@ -211,10 +204,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int $this->configuration->mustMatchGitDiff() ); - foreach ($phpFileInfos as $phpFileInfo) { - $this->linter->lintFile($phpFileInfo); - } - $this->additionalAutoloader->autoloadWithInputAndSource($input, $source); $this->rectorApplication->runOnFileInfos($phpFileInfos); diff --git a/src/Exception/Rector/InvalidRectorException.php b/src/Exception/Rector/InvalidRectorException.php new file mode 100644 index 000000000000..492a6efe0f47 --- /dev/null +++ b/src/Exception/Rector/InvalidRectorException.php @@ -0,0 +1,11 @@ +rectorNodeTraverser->getAllPhpRectors() as $phpRector) { + foreach ($phpRector->getNodeTypes() as $nodeTypeClass) { + if (is_a($nodeTypeClass, Node::class, true)) { + continue; + } + + throw new InvalidRectorException(sprintf( + 'Method "%s::getNodeTypes() provides invalid node class "%s". It must be child of "%s"', + get_class($phpRector), + $nodeTypeClass, + Node::class + )); + } + } + } } diff --git a/src/Linter/Linter.php b/src/Linter/Linter.php deleted file mode 100644 index 56666724f899..000000000000 --- a/src/Linter/Linter.php +++ /dev/null @@ -1,43 +0,0 @@ -find(); - if ($executable === false) { - throw new LintingException('PHP executable was not found'); - } - - $this->executable = $executable; - } - - public function lintFile(SmartFileInfo $smartFileInfo): void - { - $process = new Process([$this->executable, '-l', $smartFileInfo->getRealPath()]); - $process->run(); - - if ($process->isSuccessful()) { - return; - } - - throw new LintingException($process->getOutput(), (int) $process->getExitCode()); - } -}