rector/packages/PHPStanStaticTypeMapper/TypeMapper/NonEmptyArrayTypeMapper.php
Tomas Votruba 13fa9d478f Updated Rector to commit 394fa70c963bb059acd6aae4b998173bdfc6c80c
394fa70c96 [TypeDeclaration] Add FalseReturnClassMethodToNullableRector (#3229)
2022-12-20 20:40:25 +00:00

41 lines
1.1 KiB
PHP

<?php
declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\Type\Accessory\NonEmptyArrayType;
use PHPStan\Type\Type;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
/**
* @implements TypeMapperInterface<NonEmptyArrayType>
*/
final class NonEmptyArrayTypeMapper implements TypeMapperInterface
{
/**
* @return class-string<Type>
*/
public function getNodeClass() : string
{
return NonEmptyArrayType::class;
}
/**
* @param NonEmptyArrayType $type
*/
public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode
{
return new SpacingAwareArrayTypeNode(new IdentifierTypeNode('mixed'));
}
/**
* @param NonEmptyArrayType $type
*/
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
{
return new Identifier('array');
}
}