*/ final class IntersectionTypeMapper implements PhpDocTypeMapperInterface { /** * @var \Rector\StaticTypeMapper\PhpDoc\PhpDocTypeMapper */ private $phpDocTypeMapper; public function getNodeType() : string { return IntersectionTypeNode::class; } /** * @required */ public function autowire(PhpDocTypeMapper $phpDocTypeMapper) : void { $this->phpDocTypeMapper = $phpDocTypeMapper; } /** * @param IntersectionTypeNode $typeNode */ public function mapToPHPStanType(TypeNode $typeNode, Node $node, NameScope $nameScope) : Type { $intersectionedTypes = []; foreach ($typeNode->types as $intersectionedTypeNode) { $intersectionedTypes[] = $this->phpDocTypeMapper->mapToPHPStanType($intersectionedTypeNode, $node, $nameScope); } return new IntersectionType($intersectionedTypes); } }