mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 00:40:52 +00:00
7d0f151a40
a2cd7283fb
Typo fix comment php 7.3 compat on rector workflow (#3432)
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
|
|
|
use PhpParser\Node;
|
|
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
|
use PHPStan\Type\ConditionalTypeForParameter;
|
|
use PHPStan\Type\Type;
|
|
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
|
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
|
use Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper;
|
|
use RectorPrefix202303\Symfony\Contracts\Service\Attribute\Required;
|
|
/**
|
|
* @implements TypeMapperInterface<ConditionalTypeForParameter>
|
|
*/
|
|
final class ConditionalTypeForParameterMapper implements TypeMapperInterface
|
|
{
|
|
/**
|
|
* @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper
|
|
*/
|
|
private $phpStanStaticTypeMapper;
|
|
/**
|
|
* @required
|
|
*/
|
|
public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void
|
|
{
|
|
$this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper;
|
|
}
|
|
/**
|
|
* @return class-string<Type>
|
|
*/
|
|
public function getNodeClass() : string
|
|
{
|
|
return ConditionalTypeForParameter::class;
|
|
}
|
|
/**
|
|
* @param ConditionalTypeForParameter $type
|
|
* @param TypeKind::* $typeKind
|
|
*/
|
|
public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode
|
|
{
|
|
return $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getTarget(), $typeKind);
|
|
}
|
|
/**
|
|
* @param ConditionalTypeForParameter $type
|
|
* @param TypeKind::* $typeKind
|
|
*/
|
|
public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node
|
|
{
|
|
return $this->phpStanStaticTypeMapper->mapToPhpParserNode($type->getTarget(), $typeKind);
|
|
}
|
|
}
|