Skip to content

Commit

Permalink
Remove CurrentRectorProvider and used for docblock changes report, re…
Browse files Browse the repository at this point in the history
…turn bool value and node directly in the rector rule instead (#4982)
  • Loading branch information
TomasVotruba committed Sep 11, 2023
1 parent 0bb2398 commit 2e6fcde
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 90 deletions.
9 changes: 0 additions & 9 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode;
use Rector\ChangesReporting\Collector\RectorChangeCollector;
use Rector\Core\Configuration\CurrentNodeProvider;
use Rector\PhpDocParser\PhpDocParser\PhpDocNodeTraverser;
use Rector\StaticTypeMapper\StaticTypeMapper;

Expand Down Expand Up @@ -64,8 +62,6 @@ public function __construct(
private readonly StaticTypeMapper $staticTypeMapper,
private readonly \PhpParser\Node $node,
private readonly AnnotationNaming $annotationNaming,
private readonly CurrentNodeProvider $currentNodeProvider,
private readonly RectorChangeCollector $rectorChangeCollector,
private readonly PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder
) {
$this->originalPhpDocNode = clone $phpDocNode;
Expand Down Expand Up @@ -386,11 +382,6 @@ public function getTemplateTagValueNodes(): array
public function markAsChanged(): void
{
$this->hasChanged = true;

$node = $this->currentNodeProvider->getNode();
if ($node instanceof \PhpParser\Node) {
$this->rectorChangeCollector->notifyNodeFileInfo($node);
}
}

public function hasChanged(): bool
Expand Down
4 changes: 0 additions & 4 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
use Rector\ChangesReporting\Collector\RectorChangeCollector;
use Rector\Core\Configuration\CurrentNodeProvider;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\StaticTypeMapper\StaticTypeMapper;
Expand All @@ -34,7 +33,6 @@ public function __construct(
private readonly BetterPhpDocParser $betterPhpDocParser,
private readonly StaticTypeMapper $staticTypeMapper,
private readonly AnnotationNaming $annotationNaming,
private readonly RectorChangeCollector $rectorChangeCollector,
private readonly PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder
) {
}
Expand Down Expand Up @@ -137,8 +135,6 @@ private function createFromPhpDocNode(
$this->staticTypeMapper,
$node,
$this->annotationNaming,
$this->currentNodeProvider,
$this->rectorChangeCollector,
$this->phpDocNodeByTypeFinder
);

Expand Down
42 changes: 0 additions & 42 deletions packages/ChangesReporting/Collector/RectorChangeCollector.php

This file was deleted.

4 changes: 0 additions & 4 deletions packages/PostRector/Application/PostFileProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use PhpParser\Node;
use PhpParser\NodeTraverser;
use Rector\Core\Logging\CurrentRectorProvider;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\PostRector\Contract\Rector\PostRectorInterface;
Expand All @@ -27,7 +26,6 @@ final class PostFileProcessor
public function __construct(
private readonly Skipper $skipper,
private readonly CurrentFileProvider $currentFileProvider,
private readonly CurrentRectorProvider $currentRectorProvider,
// set order here
UseAddingPostRector $useAddingPostRector,
NameImportingPostRector $nameImportingPostRector,
Expand Down Expand Up @@ -57,8 +55,6 @@ public function traverse(array $stmts): array
continue;
}

$this->currentRectorProvider->changeCurrentRector($postRector);

$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor($postRector);
$stmts = $nodeTraverser->traverse($stmts);
Expand Down
2 changes: 0 additions & 2 deletions src/DependencyInjection/LazyContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
use Rector\Core\Console\Style\SymfonyStyleFactory;
use Rector\Core\Contract\DependencyInjection\ResetableInterface;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Logging\CurrentRectorProvider;
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
Expand Down Expand Up @@ -504,7 +503,6 @@ static function (AbstractRector $rector, Container $container): void {
$container->make(NodeFactory::class),
$container->make(PhpDocInfoFactory::class),
$container->make(StaticTypeMapper::class),
$container->make(CurrentRectorProvider::class),
$container->make(Skipper::class),
$container->make(ValueResolver::class),
$container->make(BetterNodeFinder::class),
Expand Down
23 changes: 0 additions & 23 deletions src/Logging/CurrentRectorProvider.php

This file was deleted.

6 changes: 0 additions & 6 deletions src/Rector/AbstractRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Rector\Core\Application\ChangedNodeScopeRefresher;
use Rector\Core\Contract\Rector\RectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Logging\CurrentRectorProvider;
use Rector\Core\NodeDecorator\CreatedByRuleDecorator;
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
Expand Down Expand Up @@ -71,8 +70,6 @@ abstract class AbstractRector extends NodeVisitorAbstract implements RectorInter

private SimpleCallableNodeTraverser $simpleCallableNodeTraverser;

private CurrentRectorProvider $currentRectorProvider;

private Skipper $skipper;

private CurrentFileProvider $currentFileProvider;
Expand All @@ -93,7 +90,6 @@ public function autowire(
NodeFactory $nodeFactory,
PhpDocInfoFactory $phpDocInfoFactory,
StaticTypeMapper $staticTypeMapper,
CurrentRectorProvider $currentRectorProvider,
Skipper $skipper,
ValueResolver $valueResolver,
BetterNodeFinder $betterNodeFinder,
Expand All @@ -108,7 +104,6 @@ public function autowire(
$this->nodeFactory = $nodeFactory;
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->staticTypeMapper = $staticTypeMapper;
$this->currentRectorProvider = $currentRectorProvider;
$this->skipper = $skipper;
$this->valueResolver = $valueResolver;
$this->betterNodeFinder = $betterNodeFinder;
Expand Down Expand Up @@ -147,7 +142,6 @@ final public function enterNode(Node $node): int|Node|null
return null;
}

$this->currentRectorProvider->changeCurrentRector($this);
$this->changedNodeScopeRefresher->reIndexNodeAttributes($node);

// ensure origNode pulled before refactor to avoid changed during refactor, ref https://3v4l.org/YMEGN
Expand Down

0 comments on commit 2e6fcde

Please sign in to comment.