2021-04-06 17:33:09 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
declare (strict_types=1);
|
2021-04-06 17:33:09 +00:00
|
|
|
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;
|
2021-08-08 00:26:40 +00:00
|
|
|
use RectorPrefix20210808\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
|
|
|
final class ArrayTypePhpDocNodeVisitor extends \RectorPrefix20210808\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
|
|
|
/**
|
2021-05-10 23:39:21 +00:00
|
|
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
2021-04-06 17:33:09 +00:00
|
|
|
*/
|
|
|
|
private $attributeMirrorer;
|
2021-05-10 22:23:08 +00:00
|
|
|
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
|
|
|
$this->attributeMirrorer = $attributeMirrorer;
|
|
|
|
}
|
2021-07-05 23:06:30 +00:00
|
|
|
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
2021-04-06 17:33:09 +00:00
|
|
|
{
|
2021-05-10 22:23:08 +00:00
|
|
|
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) {
|
2021-04-06 17:33:09 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-05-10 22:23:08 +00:00
|
|
|
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) {
|
2021-04-06 17:33:09 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-05-10 22:23:08 +00:00
|
|
|
$spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type);
|
2021-04-06 17:33:09 +00:00
|
|
|
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
|
|
|
|
return $spacingAwareArrayTypeNode;
|
|
|
|
}
|
|
|
|
}
|