mirror of https://github.com/rectorphp/rector.git
40 lines
921 B
PHP
40 lines
921 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Name;
|
|
use PHPStan\PhpDocParser\Ast\Type\ThisTypeNode;
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\Type\ThisType;
|
|
use PHPStan\Type\Type;
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
|
/**
|
|
* @implements TypeMapperInterface<ThisType>
|
|
*/
|
|
final class ThisTypeMapper implements TypeMapperInterface
|
|
{
|
|
/**
|
|
* @return class-string<Type>
|
|
*/
|
|
public function getNodeClass() : string
|
|
{
|
|
return ThisType::class;
|
|
}
|
|
/**
|
|
* @param ThisType $type
|
|
*/
|
|
public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode
|
|
{
|
|
return new ThisTypeNode();
|
|
}
|
|
/**
|
|
* @param ThisType $type
|
|
*/
|
|
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
|
{
|
|
return new Name('self');
|
|
}
|
|
}
|