2020-01-14 20:23:51 +00:00
|
|
|
<?php
|
|
|
|
|
2021-05-09 20:15:43 +00:00
|
|
|
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;
|
2021-03-19 14:33:58 +00:00
|
|
|
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
2020-01-14 20:23:51 +00:00
|
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
|
|
use PHPStan\Type\Type;
|
2021-10-25 13:44:53 +00:00
|
|
|
use Rector\Core\Enum\ObjectReference;
|
2020-01-14 20:23:51 +00:00
|
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
2021-10-27 19:25:02 +00:00
|
|
|
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
2020-12-24 16:31:24 +00:00
|
|
|
use Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType;
|
2021-06-30 11:36:37 +00:00
|
|
|
/**
|
|
|
|
* @implements TypeMapperInterface<ParentStaticType>
|
|
|
|
*/
|
2021-05-10 22:23:08 +00:00
|
|
|
final class ParentStaticTypeMapper implements \Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface
|
2020-01-14 20:23:51 +00:00
|
|
|
{
|
2021-03-06 21:16:18 +00:00
|
|
|
/**
|
|
|
|
* @return class-string<Type>
|
|
|
|
*/
|
2021-05-09 20:15:43 +00:00
|
|
|
public function getNodeClass() : string
|
2020-01-14 20:23:51 +00:00
|
|
|
{
|
2021-05-10 22:23:08 +00:00
|
|
|
return \Rector\StaticTypeMapper\ValueObject\Type\ParentStaticType::class;
|
2020-01-14 20:23:51 +00:00
|
|
|
}
|
|
|
|
/**
|
2021-12-10 10:22:23 +00:00
|
|
|
* @param ParentStaticType $type
|
2020-01-14 20:23:51 +00:00
|
|
|
*/
|
2021-12-10 10:22:23 +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
|
|
|
{
|
2021-10-25 13:44:53 +00:00
|
|
|
return new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
|
2020-01-14 20:23:51 +00:00
|
|
|
}
|
|
|
|
/**
|
2021-12-10 10:22:23 +00:00
|
|
|
* @param ParentStaticType $type
|
2020-01-14 20:23:51 +00:00
|
|
|
*/
|
2021-12-10 10:22:23 +00:00
|
|
|
public function mapToPhpParserNode(\PHPStan\Type\Type $type, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind $typeKind) : ?\PhpParser\Node
|
2020-01-14 20:23:51 +00:00
|
|
|
{
|
2021-10-25 13:44:53 +00:00
|
|
|
return new \PhpParser\Node\Name(\Rector\Core\Enum\ObjectReference::PARENT()->getValue());
|
2020-01-14 20:23:51 +00:00
|
|
|
}
|
|
|
|
}
|