PHP Класс Phan\Language\UnionType

Наследование: implements Serializable, use trait Phan\Memoize
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__clone ( ) : null After a clone is called on this object, clone our deep objects.
__construct ( Type[] | Iterator $type_list = null )
__construct ( Type[] | Iterator $type_list = null )
__toString ( ) : string
addType ( Type $type ) : void Add a type name to the list of types
addType ( Type $type ) : void Add a type name to the list of types
addUnionType ( UnionType $union_type ) : null Add the given types to this type
asClassList ( CodeBase $code_base, Context $context ) : Generator | Clazz[]
asExpandedTypes ( CodeBase $code_base, integer $recursion_depth ) : UnionType
asGenericArrayTypes ( ) : UnionType
canCastToExpandedUnionType ( UnionType $target, CodeBase $code_base ) : boolean
canCastToUnionType ( UnionType $target ) : boolean
fromFullyQualifiedString ( string $fully_qualified_string ) : UnionType
fromNode ( Context $context, CodeBase $code_base, ast\Node | string | null $node, boolean $should_catch_issue_exception = true ) : UnionType
fromStringInContext ( string $type_string, Context $context ) : UnionType
genericArrayElementTypes ( ) : UnionType Takes "a|b[]|c|d[]|e" and returns "b|d"
getTemplateParameterTypeList ( ) : array
getTemplateParameterTypeMap ( CodeBase $code_base ) : array
getTypeSet ( ) : Phan\Library\Set
hasAnyType ( array $type_list ) : boolean
hasArrayLike ( ) : boolean
hasGenericArray ( ) : boolean
hasSelfType ( ) : boolean
hasStaticType ( ) : boolean
hasTemplateType ( ) : boolean
hasType ( Type $type ) : boolean
hasType ( Type $type ) : boolean
internalFunctionSignatureMap ( ) : array
internalFunctionSignatureMapForFQSEN ( FullyQualifiedMethodName | FullyQualifiedFunctionName $function_fqsen ) : array A list of types for parameters associated with the given builtin function with the given name
internalPropertyMapForClassName ( string $class_name ) : array
isEmpty ( ) : boolean
isEqualTo ( UnionType $union_type ) : boolean
isGenericArray ( ) : boolean
isNativeType ( ) : boolean
isScalar ( ) : boolean
isType ( Type $type ) : boolean
isType ( Type $type ) : boolean
nonArrayTypes ( ) : UnionType Takes "a|b[]|c|d[]|e|array|ArrayAccess" and returns "a|c|e|ArrayAccess"
nonGenericArrayTypes ( ) : UnionType Takes "a|b[]|c|d[]|e" and returns "a|c|e"
nonNativeTypes ( ) : UnionType
removeType ( Type $type ) : void Remove a type name to the list of types
removeType ( Type $type ) : void Remove a type name to the list of types
serialize ( ) : string As per the Serializable interface
typeCount ( ) : integer
unserialize ( string $serialized ) : void As per the Serializable interface
withStaticResolvedInContext ( Context $context ) : UnionType
withTemplateParameterTypeMap ( array $template_parameter_type_map ) : UnionType

Приватные методы

Метод Описание
hasGenericType ( ) : boolean
internalPropertyMap ( ) : array

Описание методов

__clone() публичный Метод

After a clone is called on this object, clone our deep objects.
public __clone ( ) : null
Результат null

__construct() публичный Метод

public __construct ( Type[] | Iterator $type_list = null )
$type_list Type[] | Iterator An optional list of types represented by this union

__construct() публичный Метод

public __construct ( Type[] | Iterator $type_list = null )
$type_list Type[] | Iterator An optional list of types represented by this union

__toString() публичный Метод

public __toString ( ) : string
Результат string A human-readable string representation of this union type

addType() публичный Метод

Add a type name to the list of types
public addType ( Type $type ) : void
$type Type
Результат void

addType() публичный Метод

Add a type name to the list of types
public addType ( Type $type ) : void
$type Type
Результат void

addUnionType() публичный Метод

Add the given types to this type
public addUnionType ( UnionType $union_type ) : null
$union_type UnionType
Результат null

asClassList() публичный Метод

public asClassList ( CodeBase $code_base, Context $context ) : Generator | Clazz[]
$code_base Phan\CodeBase The code base in which to find classes
$context Context The context in which we're resolving this union type.
Результат Generator | Phan\Language\Element\Clazz[] A list of classes representing the non-native types associated with this UnionType

asExpandedTypes() публичный Метод

public asExpandedTypes ( CodeBase $code_base, integer $recursion_depth ) : UnionType
$code_base Phan\CodeBase
$recursion_depth integer This thing has a tendency to run-away on me. This tracks how bad I messed up by seeing how far the expanded types go
Результат UnionType Expands all class types to all inherited classes returning a superset of this type.

asGenericArrayTypes() публичный Метод

public asGenericArrayTypes ( ) : UnionType
Результат UnionType Get a new type for each type in this union which is the generic array version of this type. For instance, 'int|float' will produce 'int[]|float[]'.

canCastToExpandedUnionType() публичный Метод

public canCastToExpandedUnionType ( UnionType $target, CodeBase $code_base ) : boolean
$target UnionType The type we'd like to see if this type can cast to
$code_base Phan\CodeBase The code base used to expand types
Результат boolean Test to see if this type can be cast to the given type after expanding both union types to include all ancestor types

canCastToUnionType() публичный Метод

См. также: Phan\Deprecated\Pass2::type_check Formerly 'function type_check'
public canCastToUnionType ( UnionType $target ) : boolean
$target UnionType A type to check to see if this can cast to it
Результат boolean True if this type is allowed to cast to the given type i.e. int->float is allowed while float->int is not.

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

public static fromFullyQualifiedString ( string $fully_qualified_string ) : UnionType
$fully_qualified_string string A '|' delimited string representing a type in the form 'int|string|null|ClassName'.
Результат UnionType

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

public static fromNode ( Context $context, CodeBase $code_base, ast\Node | string | null $node, boolean $should_catch_issue_exception = true ) : UnionType
$context Context The context of the parser at the node for which we'd like to determine a type
$code_base Phan\CodeBase The code base within which we're operating
$node ast\Node | string | null The node for which we'd like to determine its type
$should_catch_issue_exception boolean Set to true to cause loggable issues to be thrown instead of emitted as issues to the log.
Результат UnionType

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

public static fromStringInContext ( string $type_string, Context $context ) : UnionType
$type_string string A '|' delimited string representing a type in the form 'int|string|null|ClassName'.
$context Context The context in which the type string was found
Результат UnionType

genericArrayElementTypes() публичный Метод

Takes "a|b[]|c|d[]|e" and returns "b|d"
public genericArrayElementTypes ( ) : UnionType
Результат UnionType The subset of types in this

getTemplateParameterTypeList() публичный Метод

public getTemplateParameterTypeList ( ) : array
Результат array A map from template type identifiers to the UnionType to replace it with

getTemplateParameterTypeMap() публичный Метод

public getTemplateParameterTypeMap ( CodeBase $code_base ) : array
$code_base Phan\CodeBase The code base to look up classes against
Результат array A map from template type identifiers to the UnionType to replace it with

getTypeSet() публичный Метод

public getTypeSet ( ) : Phan\Library\Set
Результат Phan\Library\Set The set of simple types associated with this union type.

hasAnyType() публичный Метод

public hasAnyType ( array $type_list ) : boolean
$type_list array A list of types
Результат boolean True if this union type contains any of the given named types

hasArrayLike() публичный Метод

public hasArrayLike ( ) : boolean
Результат boolean True if this union has array-like types (is of type array, is a generic array, or implements ArrayAccess).

hasGenericArray() публичный Метод

public hasGenericArray ( ) : boolean
Результат boolean True if this type has any generic types

hasSelfType() публичный Метод

public hasSelfType ( ) : boolean
Результат boolean True if this type has a type referencing the class context in which it exists such as 'self' or '$this'

hasStaticType() публичный Метод

public hasStaticType ( ) : boolean
Результат boolean True if this type has a type referencing the class context 'static'.

hasTemplateType() публичный Метод

public hasTemplateType ( ) : boolean
Результат boolean True if this union type has any types that are generic types

hasType() публичный Метод

public hasType ( Type $type ) : boolean
$type Type
Результат boolean True if this union type contains the given named type.

hasType() публичный Метод

public hasType ( Type $type ) : boolean
$type Type
Результат boolean True if this union type contains the given named type.

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

См. также: Phan\Language\Internal\FunctionSignatureMap
public static internalFunctionSignatureMap ( ) : array
Результат array A map from builtin function name to type information

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

A list of types for parameters associated with the given builtin function with the given name
См. также: internal_varargs_check Formerly `function internal_varargs_check`
public static internalFunctionSignatureMapForFQSEN ( FullyQualifiedMethodName | FullyQualifiedFunctionName $function_fqsen ) : array
$function_fqsen Phan\Language\FQSEN\FullyQualifiedMethodName | Phan\Language\FQSEN\FullyQualifiedFunctionName
Результат array

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

public static internalPropertyMapForClassName ( string $class_name ) : array
$class_name string
Результат array Get a map from property name to its type for the given class name.

isEmpty() публичный Метод

public isEmpty ( ) : boolean
Результат boolean True if this Union has no types

isEqualTo() публичный Метод

public isEqualTo ( UnionType $union_type ) : boolean
$union_type UnionType
Результат boolean True iff this union contains the exact set of types represented in the given union type.

isGenericArray() публичный Метод

public isGenericArray ( ) : boolean
Результат boolean True if this is exclusively generic types

isNativeType() публичный Метод

public isNativeType ( ) : boolean
Результат boolean True if this UnionType is exclusively native types

isScalar() публичный Метод

См. также: Phan\Deprecated\Util::type_scalar Formerly `function type_scalar`
public isScalar ( ) : boolean
Результат boolean True if all types in this union are scalars

isType() публичный Метод

public isType ( Type $type ) : boolean
$type Type
Результат boolean True if and only if this UnionType contains the given type and no others.

isType() публичный Метод

public isType ( Type $type ) : boolean
$type Type
Результат boolean True if and only if this UnionType contains the given type and no others.

nonArrayTypes() публичный Метод

Takes "a|b[]|c|d[]|e|array|ArrayAccess" and returns "a|c|e|ArrayAccess"
См. также: nonGenericArrayTypes
public nonArrayTypes ( ) : UnionType
Результат UnionType A UnionType with generic types(as well as the non-generic type "array") filtered out.

nonGenericArrayTypes() публичный Метод

Takes "a|b[]|c|d[]|e" and returns "a|c|e"
См. также: Phan\Deprecated\Pass2::nongenerics Formerly `function nongenerics`
public nonGenericArrayTypes ( ) : UnionType
Результат UnionType A UnionType with generic types filtered out

nonNativeTypes() публичный Метод

public nonNativeTypes ( ) : UnionType
Результат UnionType Get the subset of types which are not native

removeType() публичный Метод

Remove a type name to the list of types
public removeType ( Type $type ) : void
$type Type
Результат void

removeType() публичный Метод

Remove a type name to the list of types
public removeType ( Type $type ) : void
$type Type
Результат void

serialize() публичный Метод

As per the Serializable interface
См. также: Serializable
public serialize ( ) : string
Результат string A serialized representation of this type

typeCount() публичный Метод

public typeCount ( ) : integer
Результат integer The number of types in this union type

unserialize() публичный Метод

As per the Serializable interface
См. также: Serializable
public unserialize ( string $serialized ) : void
$serialized string A serialized UnionType
Результат void

withStaticResolvedInContext() публичный Метод

public withStaticResolvedInContext ( Context $context ) : UnionType
$context Context
Результат UnionType A new UnionType with any references to 'static' resolved in the given context.

withTemplateParameterTypeMap() публичный Метод

public withTemplateParameterTypeMap ( array $template_parameter_type_map ) : UnionType
$template_parameter_type_map array A map from template type identifiers to concrete types
Результат UnionType This UnionType with any template types contained herein mapped to concrete types defined in the given map.