rector/packages/NodeTypeResolver/PhpDoc/NodeAnalyzer/DocBlockNameImporter.php
Abdul Malik Ikhsan fc10fce13d
[Rectify] [Php81] Enable Rectify on Readonly Property only (#1384)
* 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>
2021-12-04 15:32:52 +03:00

32 lines
970 B
PHP

<?php
declare(strict_types=1);
namespace Rector\NodeTypeResolver\PhpDoc\NodeAnalyzer;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
use Rector\NodeTypeResolver\PhpDoc\PhpDocNodeTraverser\ImportingPhpDocNodeTraverserFactory;
use Rector\NodeTypeResolver\PhpDocNodeVisitor\NameImportingPhpDocNodeVisitor;
final class DocBlockNameImporter
{
public function __construct(
private readonly NameImportingPhpDocNodeVisitor $nameImportingPhpDocNodeVisitor,
private readonly ImportingPhpDocNodeTraverserFactory $importingPhpDocNodeTraverserFactory
) {
}
public function importNames(PhpDocNode $phpDocNode, Node $node): void
{
if ($phpDocNode->children === []) {
return;
}
$this->nameImportingPhpDocNodeVisitor->setCurrentNode($node);
$phpDocNodeTraverser = $this->importingPhpDocNodeTraverserFactory->create();
$phpDocNodeTraverser->traverse($phpDocNode);
}
}