mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-13 14:42:23 +00:00
fc10fce13d
* re-enable rectify and ecs * [Rectify] [Php81] Enable Rectify on Readonly Property only * comment * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify * [ci-review] Rector Rectify Co-authored-by: GitHub Action <action@github.com>
51 lines
2.0 KiB
PHP
51 lines
2.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\BetterPhpDocParser;
|
|
|
|
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
|
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
|
use Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider;
|
|
use Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator;
|
|
use Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
|
use Symplify\SimplePhpDocParser\PhpDocNodeVisitor\CloningPhpDocNodeVisitor;
|
|
use Symplify\SimplePhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitor;
|
|
|
|
/**
|
|
* @see \Rector\Tests\BetterPhpDocParser\PhpDocNodeMapperTest
|
|
*/
|
|
final class PhpDocNodeMapper
|
|
{
|
|
/**
|
|
* @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors
|
|
*/
|
|
public function __construct(
|
|
private readonly CurrentTokenIteratorProvider $currentTokenIteratorProvider,
|
|
private readonly ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor,
|
|
private readonly CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor,
|
|
private readonly array $phpDocNodeVisitors
|
|
) {
|
|
}
|
|
|
|
public function transform(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator): void
|
|
{
|
|
$this->currentTokenIteratorProvider->setBetterTokenIterator($betterTokenIterator);
|
|
|
|
$parentPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
|
$parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor);
|
|
$parentPhpDocNodeTraverser->traverse($phpDocNode);
|
|
|
|
$cloningPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
|
$cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor);
|
|
$cloningPhpDocNodeTraverser->traverse($phpDocNode);
|
|
|
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
|
foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) {
|
|
$phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor);
|
|
}
|
|
|
|
$phpDocNodeTraverser->traverse($phpDocNode);
|
|
}
|
|
}
|