mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-15 15:42:22 +00:00
a9ffd906d7
368dbb048c
docs: fix instruction in CONTRIBUTING.md (#2470)
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
|
|
|
|
use PHPStan\PhpDocParser\Ast\Node;
|
|
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
|
|
use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
|
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
|
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
|
use RectorPrefix20220610\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
|
final class CallableTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
|
*/
|
|
private $attributeMirrorer;
|
|
public function __construct(AttributeMirrorer $attributeMirrorer)
|
|
{
|
|
$this->attributeMirrorer = $attributeMirrorer;
|
|
}
|
|
public function enterNode(Node $node) : ?Node
|
|
{
|
|
if (!$node instanceof CallableTypeNode) {
|
|
return null;
|
|
}
|
|
if ($node instanceof SpacingAwareCallableTypeNode) {
|
|
return null;
|
|
}
|
|
$spacingAwareCallableTypeNode = new SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType);
|
|
$this->attributeMirrorer->mirror($node, $spacingAwareCallableTypeNode);
|
|
return $spacingAwareCallableTypeNode;
|
|
}
|
|
}
|