Phan\Language\Type::fromFullyQualifiedString PHP Метод

fromFullyQualifiedString() публичный статический Метод

public static fromFullyQualifiedString ( string $fully_qualified_string ) : Type
$fully_qualified_string string A fully qualified type name
Результат Type
    public static function fromFullyQualifiedString(string $fully_qualified_string) : Type
    {
        assert(!empty($fully_qualified_string), "Type cannot be empty");
        if (0 !== strpos($fully_qualified_string, '\\')) {
            return self::fromInternalTypeName($fully_qualified_string);
        }
        $tuple = self::typeStringComponents($fully_qualified_string);
        $namespace = $tuple->_0;
        $type_name = $tuple->_1;
        $template_parameter_type_name_list = $tuple->_2;
        // Map the names of the types to actual types in the
        // template parameter type list
        $template_parameter_type_list = array_map(function (string $type_name) {
            return Type::fromFullyQualifiedString($type_name)->asUnionType();
        }, $template_parameter_type_name_list);
        if (0 !== strpos($namespace, '\\')) {
            $namespace = '\\' . $namespace;
        }
        assert(!empty($namespace) && !empty($type_name), "Type was not fully qualified");
        return self::make($namespace, $type_name, $template_parameter_type_list);
    }

Usage Example

Пример #1
0
 /**
  * @param string $fully_qualified_string
  * A '|' delimited string representing a type in the form
  * 'int|string|null|ClassName'.
  *
  * @param Context $context
  * The context in which the type string was
  * found
  *
  * @return UnionType
  */
 public static function fromFullyQualifiedString(string $fully_qualified_string) : UnionType
 {
     if (empty($fully_qualified_string)) {
         return new UnionType();
     }
     return new UnionType(array_map(function (string $type_name) {
         return Type::fromFullyQualifiedString($type_name);
     }, explode('|', $fully_qualified_string)));
 }
All Usage Examples Of Phan\Language\Type::fromFullyQualifiedString