mirror of https://github.com/rectorphp/rector.git
41 lines
1.1 KiB
PHP
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) : TypeNode
|
|
{
|
|
return new SpacingAwareArrayTypeNode(new IdentifierTypeNode('mixed'));
|
|
}
|
|
/**
|
|
* @param NonEmptyArrayType $type
|
|
*/
|
|
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
|
{
|
|
return new Identifier('array');
|
|
}
|
|
}
|