mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-30 22:53:31 +00:00
3266f22182
1d409bc35b
safe by default
42 lines
1.5 KiB
PHP
42 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Name;
|
|
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\Type\Type;
|
|
use Rector\Core\Enum\ObjectReference;
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
|
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
|
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
|
/**
|
|
* @implements TypeMapperInterface<ParentStaticType>
|
|
*/
|
|
final class ParentStaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface
|
|
{
|
|
/**
|
|
* @return class-string<Type>
|
|
*/
|
|
public function getNodeClass() : string
|
|
{
|
|
return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType::class;
|
|
}
|
|
/**
|
|
* @param ParentStaticType $type
|
|
*/
|
|
public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
|
{
|
|
return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
|
|
}
|
|
/**
|
|
* @param ParentStaticType $type
|
|
*/
|
|
public function mapToPhpParserNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node
|
|
{
|
|
return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
|
|
}
|
|
}
|