rector/packages/BetterPhpDocParser/PhpDocNodeVisitor/ArrayTypePhpDocNodeVisitor.php
Tomas Votruba 9200bbb091 Updated Rector to commit 9d74e20acb
9d74e20acb [Dep] Add PHPUnit\Framework\TestCase stub on target-repository bootstrap.php (#1924)
2022-03-12 17:33:54 +00:00

36 lines
1.6 KiB
PHP

<?php
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode;
use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
use RectorPrefix20220312\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class ArrayTypePhpDocNodeVisitor extends \RectorPrefix20220312\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
{
/**
* @readonly
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
{
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) {
return null;
}
$spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type);
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
return $spacingAwareArrayTypeNode;
}
}