mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-28 21:53:31 +00:00
37 lines
1.1 KiB
PHP
37 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\StaticTypeMapper\PhpParser;
|
|
|
|
use PhpParser\Node;
|
|
use PhpParser\Node\Identifier;
|
|
use PHPStan\Type\Type;
|
|
use Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface;
|
|
use Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper;
|
|
/**
|
|
* @implements PhpParserNodeMapperInterface<Identifier>
|
|
*/
|
|
final class IdentifierNodeMapper implements \Rector\StaticTypeMapper\Contract\PhpParser\PhpParserNodeMapperInterface
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper
|
|
*/
|
|
private $scalarStringToTypeMapper;
|
|
public function __construct(\Rector\StaticTypeMapper\Mapper\ScalarStringToTypeMapper $scalarStringToTypeMapper)
|
|
{
|
|
$this->scalarStringToTypeMapper = $scalarStringToTypeMapper;
|
|
}
|
|
public function getNodeType() : string
|
|
{
|
|
return \PhpParser\Node\Identifier::class;
|
|
}
|
|
/**
|
|
* @param Identifier $node
|
|
*/
|
|
public function mapToPHPStan(\PhpParser\Node $node) : \PHPStan\Type\Type
|
|
{
|
|
return $this->scalarStringToTypeMapper->mapScalarStringToType($node->name);
|
|
}
|
|
}
|