mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-13 22:52: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>
37 lines
1.1 KiB
PHP
37 lines
1.1 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 Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
|
|
|
final class ArrayTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
|
{
|
|
public function __construct(
|
|
private readonly AttributeMirrorer $attributeMirrorer
|
|
) {
|
|
}
|
|
|
|
public function enterNode(Node $node): ?Node
|
|
{
|
|
if (! $node instanceof ArrayTypeNode) {
|
|
return null;
|
|
}
|
|
|
|
if ($node instanceof SpacingAwareArrayTypeNode) {
|
|
return null;
|
|
}
|
|
|
|
$spacingAwareArrayTypeNode = new SpacingAwareArrayTypeNode($node->type);
|
|
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
|
|
|
|
return $spacingAwareArrayTypeNode;
|
|
}
|
|
}
|