rector/packages/PHPStanStaticTypeMapper/TypeMapper/ParentStaticTypeMapper.php

42 lines
1.5 KiB
PHP
Raw Normal View History

2020-01-14 20:23:51 +00:00
<?php
declare (strict_types=1);
2020-01-14 20:23:51 +00:00
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
2020-05-10 21:02:46 +00:00
use PhpParser\Node\Name;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
2020-01-14 20:23:51 +00:00
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Type;
use Rector\Core\Enum\ObjectReference;
2020-01-14 20:23:51 +00:00
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
2020-01-14 20:23:51 +00:00
{
/**
* @return class-string<Type>
*/
public function getNodeClass() : string
2020-01-14 20:23:51 +00:00
{
return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType::class;
2020-01-14 20:23:51 +00:00
}
/**
* @param ParentStaticType $type
2020-01-14 20:23:51 +00:00
*/
public function mapToPHPStanPhpDocTypeNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
2020-01-14 20:23:51 +00:00
{
return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
2020-01-14 20:23:51 +00:00
}
/**
* @param ParentStaticType $type
2020-01-14 20:23:51 +00:00
*/
public function mapToPhpParserNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node
2020-01-14 20:23:51 +00:00
{
return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
2020-01-14 20:23:51 +00:00
}
}