mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-28 05:33:30 +00:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|
|
|
use PhpParser\Node;
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\Type\ResourceType;
|
|
use PHPStan\Type\Type;
|
|
use PHPStan\Type\VerbosityLevel;
|
|
use Rector\AttributeAwarePhpDoc\Ast\Type\AttributeAwareIdentifierTypeNode;
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
|
|
|
final class ResourceTypeMapper implements TypeMapperInterface
|
|
{
|
|
public function getNodeClass(): string
|
|
{
|
|
return ResourceType::class;
|
|
}
|
|
|
|
/**
|
|
* @param ResourceType $type
|
|
*/
|
|
public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
|
|
{
|
|
return new AttributeAwareIdentifierTypeNode('resource');
|
|
}
|
|
|
|
/**
|
|
* @param ResourceType $type
|
|
*/
|
|
public function mapToPhpParserNode(Type $type, ?string $kind = null): ?Node
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public function mapToDocString(Type $type, ?Type $parentType = null): string
|
|
{
|
|
return $type->describe(VerbosityLevel::typeOnly());
|
|
}
|
|
}
|