PATH:
opt
/
cpanel
/
ea-wappspector
/
vendor
/
rector
/
rector
/
src
/
PHPStanStaticTypeMapper
/
TypeMapper
<?php declare (strict_types=1); namespace Rector\PHPStanStaticTypeMapper\TypeMapper; use PhpParser\Node; use PhpParser\Node\Name; use PHPStan\PhpDocParser\Ast\Type\TypeNode; use PHPStan\Type\StaticType; use PHPStan\Type\Type; use Rector\Enum\ObjectReference; use Rector\Php\PhpVersionProvider; use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; use Rector\StaticTypeMapper\ValueObject\Type\SelfStaticType; use Rector\StaticTypeMapper\ValueObject\Type\SimpleStaticType; use Rector\ValueObject\PhpVersionFeature; /** * @see \Rector\Tests\NodeTypeResolver\StaticTypeMapper\StaticTypeMapperTest * * @implements TypeMapperInterface<StaticType> */ final class StaticTypeMapper implements TypeMapperInterface { /** * @readonly * @var \Rector\Php\PhpVersionProvider */ private $phpVersionProvider; public function __construct(PhpVersionProvider $phpVersionProvider) { $this->phpVersionProvider = $phpVersionProvider; } public function getNodeClass() : string { return StaticType::class; } /** * @param StaticType $type */ public function mapToPHPStanPhpDocTypeNode(Type $type) : TypeNode { return $type->toPhpDocNode(); } /** * @param SimpleStaticType|StaticType $type */ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { if ($type instanceof SelfStaticType) { return new Name(ObjectReference::SELF); } if ($typeKind !== TypeKind::RETURN) { return new Name(ObjectReference::SELF); } if (!$this->phpVersionProvider->isAtLeastPhpVersion(PhpVersionFeature::STATIC_RETURN_TYPE)) { return new Name(ObjectReference::SELF); } return new Name(ObjectReference::STATIC); } }
[-] MixedTypeMapper.php
[edit]
[-] NeverTypeMapper.php
[edit]
[-] ObjectWithoutClassTypeMapper.php
[edit]
[-] ResourceTypeMapper.php
[edit]
[-] NonEmptyArrayTypeMapper.php
[edit]
[-] HasOffsetValueTypeTypeMapper.php
[edit]
[-] StringTypeMapper.php
[edit]
[-] IntegerTypeMapper.php
[edit]
[-] ArrayTypeMapper.php
[edit]
[-] IntersectionTypeMapper.php
[edit]
[+]
..
[-] ClosureTypeMapper.php
[edit]
[-] ConditionalTypeMapper.php
[edit]
[-] HasPropertyTypeMapper.php
[edit]
[-] ParentStaticTypeMapper.php
[edit]
[-] CallableTypeMapper.php
[edit]
[-] StrictMixedTypeMapper.php
[edit]
[-] GenericClassStringTypeMapper.php
[edit]
[-] VoidTypeMapper.php
[edit]
[-] ClassStringTypeMapper.php
[edit]
[-] UnionTypeMapper.php
[edit]
[-] ThisTypeMapper.php
[edit]
[-] OversizedArrayTypeMapper.php
[edit]
[-] AccessoryNonEmptyStringTypeMapper.php
[edit]
[-] TypeWithClassNameTypeMapper.php
[edit]
[-] FloatTypeMapper.php
[edit]
[-] HasMethodTypeMapper.php
[edit]
[-] ObjectTypeMapper.php
[edit]
[-] BooleanTypeMapper.php
[edit]
[-] NullTypeMapper.php
[edit]
[-] HasOffsetTypeMapper.php
[edit]
[-] AccessoryNumericStringTypeMapper.php
[edit]
[-] SelfObjectTypeMapper.php
[edit]
[-] StaticTypeMapper.php
[edit]
[-] ConditionalTypeForParameterMapper.php
[edit]
[-] AccessoryNonFalsyStringTypeMapper.php
[edit]
[-] IterableTypeMapper.php
[edit]
[-] AccessoryLiteralStringTypeMapper.php
[edit]