mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 01:10:53 +00:00
decouple CallableTypeMapper, ClosureTypeMapper
This commit is contained in:
parent
35911cb872
commit
5aac9a3d69
|
@ -122,14 +122,6 @@ final class PHPStanStaticTypeMapper
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($phpStanType instanceof CallableType || $phpStanType instanceof ClosureType) {
|
||||
if ($kind === 'property') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Identifier('callable');
|
||||
}
|
||||
|
||||
if ($phpStanType instanceof TypeWithClassName) {
|
||||
$lowerCasedClassName = strtolower($phpStanType->getClassName());
|
||||
if ($lowerCasedClassName === 'callable') {
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\CallableType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Exception\NotImplementedException;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
|
||||
final class CallableTypeMapper implements TypeMapperInterface
|
||||
{
|
||||
public function getNodeClass(): string
|
||||
{
|
||||
return CallableType::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CallableType $type
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param CallableType $type
|
||||
*/
|
||||
public function mapToPhpParserNode(Type $type, ?string $kind = null): ?Node
|
||||
{
|
||||
if ($kind === 'property') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Identifier('callable');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
use PHPStan\Type\ClosureType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Exception\NotImplementedException;
|
||||
use Rector\PHPStanStaticTypeMapper\Contract\TypeMapperInterface;
|
||||
|
||||
final class ClosureTypeMapper implements TypeMapperInterface
|
||||
{
|
||||
public function getNodeClass(): string
|
||||
{
|
||||
return ClosureType::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClosureType $type
|
||||
*/
|
||||
public function mapToPHPStanPhpDocTypeNode(Type $type): TypeNode
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClosureType $type
|
||||
*/
|
||||
public function mapToPhpParserNode(Type $type, ?string $kind = null): ?Node
|
||||
{
|
||||
if ($kind === 'property') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Identifier('callable');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user