Phan\Language\Type::fromType PHP Method

fromType() public static method

public static fromType ( Type $type, UnionType[] $template_parameter_type_list ) : Type
$type Type The base type of this generic type referencing a generic class
$template_parameter_type_list UnionType[] A map from a template type identifier to a concrete union type
return Type
    public static function fromType(Type $type, $template_parameter_type_list) : Type
    {
        return self::make($type->getNamespace(), $type->getName(), $template_parameter_type_list);
    }

Same methods

Type::fromType ( Type $type, UnionType[] $template_parameter_type_list ) : Type

Usage Example

Example #1
0
File: Clazz.php Project: etsy/phan
 /**
  * @param Type|null $parent_type
  * The type of the parent (extended) class of this class.
  *
  * @return void
  */
 public function setParentType(Type $parent_type = null)
 {
     if ($this->getInternalScope()->hasAnyTemplateType()) {
         // Get a reference to the local list of templated
         // types. We'll use this to map templated types on the
         // parent to locally templated types.
         $template_type_map = $this->getInternalScope()->getTemplateTypeMap();
         // Figure out if the given parent type contains any template
         // types.
         $contains_templated_type = false;
         foreach ($parent_type->getTemplateParameterTypeList() as $i => $union_type) {
             foreach ($union_type->getTypeSet() as $type) {
                 if (isset($template_type_map[$type->getName()])) {
                     $contains_templated_type = true;
                     break 2;
                 }
             }
         }
         // If necessary, map the template parameter type list through the
         // local list of templated types.
         if ($contains_templated_type) {
             $parent_type = Type::fromType($parent_type, array_map(function (UnionType $union_type) use($template_type_map) : UnionType {
                 return new UnionType(array_map(function (Type $type) use($template_type_map) : Type {
                     return $template_type_map[$type->getName()] ?? $type;
                 }, $union_type->getTypeSet()->toArray()));
             }, $parent_type->getTemplateParameterTypeList()));
         }
     }
     $this->parent_type = $parent_type;
     // Add the parent to the union type of this
     // class
     $this->getUnionType()->addUnionType($parent_type->asUnionType());
 }
All Usage Examples Of Phan\Language\Type::fromType