Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,11 +85,6 @@ final class ProcessCommand extends AbstractCommand
*/
private $paths = [];

/**
* @var Linter
*/
private $linter;

/**
* @param string[] $paths
* @param string[] $fileExtensions
Expand All @@ -106,7 +100,6 @@ public function __construct(
ReportingExtensionRunner $reportingExtensionRunner,
RectorNodeTraverser $rectorNodeTraverser,
StubLoader $stubLoader,
Linter $linter,
array $paths,
array $fileExtensions
) {
Expand All @@ -122,7 +115,6 @@ public function __construct(
$this->rectorNodeTraverser = $rectorNodeTraverser;
$this->stubLoader = $stubLoader;
$this->paths = $paths;
$this->linter = $linter;

parent::__construct();
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions src/Exception/Rector/InvalidRectorException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Exception\Rector;

use Exception;

final class InvalidRectorException extends Exception
{
}
20 changes: 20 additions & 0 deletions src/Guard/RectorGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace Rector\Guard;

use PhpParser\Node;
use Rector\Exception\NoRectorsLoadedException;
use Rector\Exception\Rector\InvalidRectorException;
use Rector\FileSystemRector\FileSystemFileProcessor;
use Rector\PhpParser\NodeTraverser\RectorNodeTraverser;

Expand Down Expand Up @@ -45,4 +47,22 @@ public function ensureSomeRectorsAreRegistered(): void
PHP_EOL
));
}

public function ensureGetNodeTypesAreNodes(): void
{
foreach ($this->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
));
}
}
}
}
43 changes: 0 additions & 43 deletions src/Linter/Linter.php

This file was deleted.