mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
bdfd24339f
2e977bd3aa
deploy to original repository
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|
|
|
use PhpParser\Node;
|
|
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\Type\NeverType;
|
|
use PHPStan\Type\Type;
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
|
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
|
/**
|
|
* @implements TypeMapperInterface<NeverType>
|
|
*/
|
|
final class NeverTypeMapper implements TypeMapperInterface
|
|
{
|
|
/**
|
|
* @return class-string<Type>
|
|
*/
|
|
public function getNodeClass() : string
|
|
{
|
|
return NeverType::class;
|
|
}
|
|
/**
|
|
* @param TypeKind::* $typeKind
|
|
* @param NeverType $type
|
|
*/
|
|
public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode
|
|
{
|
|
if ($typeKind === TypeKind::RETURN) {
|
|
return new IdentifierTypeNode('never');
|
|
}
|
|
return new IdentifierTypeNode('mixed');
|
|
}
|
|
/**
|
|
* @param NeverType $type
|
|
*/
|
|
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
|
{
|
|
return null;
|
|
}
|
|
}
|