rector/packages/phpstan-static-type-mapper/src/TypeMapper/ClassStringTypeMapper.php
Tomas Votruba 351e59fa3b
Fix array type (#4058)
Co-authored-by: rector-bot <tomas@getrector.org>
2020-08-29 16:20:27 +02:00

46 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\ClassStringType;
use PHPStan\Type\Type;
use PHPStan\Type\VerbosityLevel;
use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIdentifierTypeNode;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
final class ClassStringTypeMapper implements TypeMapperInterface
{
public function getNodeClass(): string
{
return ClassStringType::class;
}
/**
* @param ClassStringType $type
*/
public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
{
return new AttributeAwareIdentifierTypeNode('class-string');
}
/**
* @param ClassStringType $type
*/
public function mapToPhpParserNode(Type $type, ?string $kind = null): ?Node
{
return null;
}
/**
* @param ClassStringType $type
*/
public function mapToDocString(Type $type, ?Type $parentType = null): string
{
return $type->describe(VerbosityLevel::typeOnly());
}
}