*/ final class CallableTypeMapper implements TypeMapperInterface { /** * @var \Rector\PHPStanStaticTypeMapper\PHPStanStaticTypeMapper */ private $phpStanStaticTypeMapper; /** * @required */ public function autowire(PHPStanStaticTypeMapper $phpStanStaticTypeMapper) : void { $this->phpStanStaticTypeMapper = $phpStanStaticTypeMapper; } /** * @return class-string */ public function getNodeClass() : string { return CallableType::class; } /** * @param TypeKind::* $typeKind * @param CallableType $type */ public function mapToPHPStanPhpDocTypeNode(Type $type, string $typeKind) : TypeNode { $returnTypeNode = $this->phpStanStaticTypeMapper->mapToPHPStanPhpDocTypeNode($type->getReturnType(), $typeKind); return new SpacingAwareCallableTypeNode(new IdentifierTypeNode('callable'), [], $returnTypeNode); } /** * @param TypeKind::* $typeKind * @param CallableType|ClosureType $type */ public function mapToPhpParserNode(Type $type, string $typeKind) : ?Node { if ($typeKind === TypeKind::PROPERTY) { return null; } return new Identifier('callable'); } }