MutableUnion
in package
implements
TypeNode
uses
UnionTrait
Table of Contents
Interfaces
Properties
- $allow_mutations : bool
- $by_ref : bool
- True if the type was passed or returned by reference, or if the type refers to an object's property or an item in an array. Note that this is not true for locally created references that don't refer to properties or array items (see Context::$references_in_scope).
- $checked : bool
- Whether or not the type has been checked yet
- $different : bool
- $explicit_never : bool
- whether this type had never set explicitly since it's the bottom type, it's combined into everything else and lost
- $failed_reconciliation : bool
- $from_calculation : bool
- Whether the type originated from integer calculation
- $from_docblock : bool
- Whether the type originated in a docblock
- $from_property : bool
- Whether the type originated from a property
- $from_static_property : bool
- Whether the type originated from *static* property
- $from_template_default : bool
- Whether or not this union comes from a template "as" default
- $had_template : bool
- Whether or not this union had a template, since replaced
- $has_mutations : bool
- $ignore_falsable_issues : bool
- Whether or not to ignore issues with possibly-false values
- $ignore_isset : bool
- Whether or not to ignore issues with isset on this type
- $ignore_nullable_issues : bool
- Whether or not to ignore issues with possibly-null values
- $initialized : bool
- Whether the property that this type has been derived from has been initialized in a constructor
- $initialized_class : string|null
- Which class the type was initialised in
- $parent_nodes : array<string, DataFlowNode>
- $possibly_undefined : bool
- Whether or not this variable is possibly undefined
- $possibly_undefined_from_try : bool
- Whether or not this variable is possibly undefined
- $propagate_parent_nodes : bool
- $reference_free : bool
- $exact_id : string|null
- This is a cache of getId on exact mode
- $id : string|null
- This is a cache of getId on non-exact mode
- $literal_float_types : array<string, TLiteralFloat>
- $literal_int_types : array<string, TLiteralInt>
- $literal_string_types : array<string, TLiteralString>
- $typed_class_strings : array<string, TClassString>
- $types : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructs a Union instance
- __toString() : string
- addType() : self
- allFloatLiterals() : bool
- allIntLiterals() : bool
- allLiterals() : bool
- allSpecificLiterals() : bool
- allStringLiterals() : bool
- bustCache() : void
- canBeFullyExpressedInPhp() : bool
- canContainObjectType() : bool
- check() : bool
- containsAnyLiteral() : bool
- containsClassLike() : bool
- equals() : bool
- freeze() : Union
- getArray() : TArray|TKeyedArray|TClassStringMap
- getAtomicTypes() : array<string|int, mixed>
- getBuilder() : self
- getCallableTypes() : array<string, TCallable>
- getClosureTypes() : array<string, TClosure>
- getId() : string
- getKey() : string
- getLiteralFloats() : array<string, TLiteralFloat>
- getLiteralInts() : array<string, TLiteralInt>
- getLiteralStrings() : array<string, TLiteralString>
- getRangeInts() : array<string, TIntRange>
- getSingleAtomic() : Atomic
- getSingleFloatLiteral() : TLiteralFloat
- getSingleIntLiteral() : TLiteralInt
- getSingleLiteral() : TLiteralInt|TLiteralString|TLiteralFloat
- getSingleStringLiteral() : TLiteralString
- getTemplateTypes() : array<int, TTemplateParam>
- hasArray() : bool
- hasArrayAccessInterface() : bool
- hasArrayKey() : bool
- hasBool() : bool
- hasCallableType() : bool
- hasClassStringMap() : bool
- hasConditional() : bool
- hasFloat() : bool
- hasInt() : bool
- hasIterable() : bool
- hasList() : bool
- hasLiteralClassString() : bool
- hasLiteralFloat() : bool
- hasLiteralInt() : bool
- hasLiteralString() : bool
- hasLiteralValue() : bool
- hasLowercaseString() : bool
- hasMixed() : bool
- hasNamedObjectType() : bool
- hasNull() : bool
- hasNumeric() : bool
- hasObject() : bool
- hasObjectType() : bool
- hasScalar() : bool
- hasScalarType() : bool
- hasStaticObject() : bool
- hasString() : bool
- hasTemplate() : bool
- hasTemplateOrStatic() : bool
- hasType() : bool
- isAlwaysFalsy() : bool
- isAlwaysTruthy() : bool
- isArray() : bool
- isArrayKey() : bool
- isBool() : bool
- isEmptyArray() : bool
- isEmptyMixed() : bool
- isFalsable() : bool
- isFalse() : bool
- isFloat() : bool
- isGenerator() : bool
- isInt() : bool
- isMixed() : bool
- isNever() : bool
- isNonEmptyString() : bool
- isNull() : bool
- isNullable() : bool
- isObjectType() : bool
- isSingle() : bool
- isSingleAndMaybeNullable() : bool
- isSingleFloatLiteral() : bool
- isSingleIntLiteral() : bool
- isSingleLiteral() : bool
- isSingleStringLiteral() : bool
- isStaticObject() : bool
- isString() : bool
- isTemplatedClassString() : bool
- isTrue() : bool
- isUnionEmpty() : bool
- isVanillaMixed() : bool
- isVoid() : bool
- queueClassLikesForScanning() : void
- removeType() : bool
- replaceClassLike() : static
- setFromDocblock() : self
- setTypes() : self
- substitute() : self
- toNamespacedString() : string
- toPhpString() : string|null
- visit() : bool
- visitMutable() : bool
Properties
$allow_mutations
public
bool
$allow_mutations
= true
$by_ref
True if the type was passed or returned by reference, or if the type refers to an object's property or an item in an array. Note that this is not true for locally created references that don't refer to properties or array items (see Context::$references_in_scope).
public
bool
$by_ref
= false
$checked
Whether or not the type has been checked yet
public
bool
$checked
= false
$different
public
bool
$different
= false
$explicit_never
whether this type had never set explicitly since it's the bottom type, it's combined into everything else and lost
public
bool
$explicit_never
= false
Tags
$failed_reconciliation
public
bool
$failed_reconciliation
= false
$from_calculation
Whether the type originated from integer calculation
public
bool
$from_calculation
= false
$from_docblock
Whether the type originated in a docblock
public
bool
$from_docblock
= false
$from_property
Whether the type originated from a property
public
bool
$from_property
= false
This helps turn isset($foo->bar) into a different sort of issue
$from_static_property
Whether the type originated from *static* property
public
bool
$from_static_property
= false
Unlike non-static properties, static properties have no prescribed place like __construct() to be initialized in
$from_template_default
Whether or not this union comes from a template "as" default
public
bool
$from_template_default
= false
$had_template
Whether or not this union had a template, since replaced
public
bool
$had_template
= false
$has_mutations
public
bool
$has_mutations
= true
$ignore_falsable_issues
Whether or not to ignore issues with possibly-false values
public
bool
$ignore_falsable_issues
= false
$ignore_isset
Whether or not to ignore issues with isset on this type
public
bool
$ignore_isset
= false
$ignore_nullable_issues
Whether or not to ignore issues with possibly-null values
public
bool
$ignore_nullable_issues
= false
$initialized
Whether the property that this type has been derived from has been initialized in a constructor
public
bool
$initialized
= true
$initialized_class
Which class the type was initialised in
public
string|null
$initialized_class
= null
$parent_nodes
public
array<string, DataFlowNode>
$parent_nodes
= []
$possibly_undefined
Whether or not this variable is possibly undefined
public
bool
$possibly_undefined
= false
$possibly_undefined_from_try
Whether or not this variable is possibly undefined
public
bool
$possibly_undefined_from_try
= false
$propagate_parent_nodes
public
bool
$propagate_parent_nodes
= false
Tags
$reference_free
public
bool
$reference_free
= false
$exact_id
This is a cache of getId on exact mode
private
string|null
$exact_id
= null
$id
This is a cache of getId on non-exact mode
private
string|null
$id
= null
$literal_float_types
private
array<string, TLiteralFloat>
$literal_float_types
= []
$literal_int_types
private
array<string, TLiteralInt>
$literal_int_types
= []
$literal_string_types
private
array<string, TLiteralString>
$literal_string_types
= []
$typed_class_strings
private
array<string, TClassString>
$typed_class_strings
= []
$types
private
array<string|int, mixed>
$types
Methods
__construct()
Constructs a Union instance
public
__construct(array<string|int, mixed> $types[, TProperties $properties = [] ]) : mixed
Parameters
- $types : array<string|int, mixed>
- $properties : TProperties = []
Tags
__toString()
public
__toString() : string
Tags
Return values
stringaddType()
public
addType(Atomic $type) : self
Parameters
- $type : Atomic
Tags
Return values
selfallFloatLiterals()
public
allFloatLiterals() : bool
Tags
Return values
boolallIntLiterals()
public
allIntLiterals() : bool
Tags
Return values
boolallLiterals()
public
allLiterals() : bool
Tags
Return values
boolallSpecificLiterals()
public
allSpecificLiterals() : bool
Tags
Return values
boolallStringLiterals()
public
allStringLiterals() : bool
Tags
Return values
boolbustCache()
public
bustCache() : void
Tags
canBeFullyExpressedInPhp()
public
canBeFullyExpressedInPhp(int $analysis_php_version_id) : bool
Parameters
- $analysis_php_version_id : int
Tags
Return values
boolcanContainObjectType()
public
canContainObjectType(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Tags
Return values
boolcheck()
public
check(StatementsSource $source, CodeLocation $code_location, array<string|int, string> $suppressed_issues[, array<string, bool> $phantom_classes = [] ][, bool $inferred = true ][, bool $inherited = false ][, bool $prevent_template_covariance = false ][, string|null $calling_method_id = null ]) : bool
Parameters
- $source : StatementsSource
- $code_location : CodeLocation
- $suppressed_issues : array<string|int, string>
- $phantom_classes : array<string, bool> = []
- $inferred : bool = true
- $inherited : bool = false
- $prevent_template_covariance : bool = false
- $calling_method_id : string|null = null
Return values
boolcontainsAnyLiteral()
public
containsAnyLiteral() : bool
Tags
Return values
boolcontainsClassLike()
public
containsClassLike(lowercase-string $fq_class_like_name) : bool
Parameters
- $fq_class_like_name : lowercase-string
Tags
Return values
boolequals()
public
equals(self $other_type[, bool $ensure_source_equality = true ][, bool $ensure_parent_node_equality = true ][, bool $ensure_possibly_undefined_equality = true ]) : bool
Parameters
- $other_type : self
- $ensure_source_equality : bool = true
- $ensure_parent_node_equality : bool = true
- $ensure_possibly_undefined_equality : bool = true
Tags
Return values
boolfreeze()
public
freeze() : Union
Tags
Return values
UniongetArray()
public
getArray() : TArray|TKeyedArray|TClassStringMap
Return values
TArray|TKeyedArray|TClassStringMapgetAtomicTypes()
public
getAtomicTypes() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getBuilder()
public
getBuilder() : self
Tags
Return values
selfgetCallableTypes()
public
getCallableTypes() : array<string, TCallable>
Tags
Return values
array<string, TCallable>getClosureTypes()
public
getClosureTypes() : array<string, TClosure>
Tags
Return values
array<string, TClosure>getId()
public
getId([bool $exact = true ]) : string
Parameters
- $exact : bool = true
Tags
Return values
stringgetKey()
public
getKey() : string
Tags
Return values
stringgetLiteralFloats()
public
getLiteralFloats() : array<string, TLiteralFloat>
Tags
Return values
array<string, TLiteralFloat>getLiteralInts()
public
getLiteralInts() : array<string, TLiteralInt>
Tags
Return values
array<string, TLiteralInt>getLiteralStrings()
public
getLiteralStrings() : array<string, TLiteralString>
Tags
Return values
array<string, TLiteralString>getRangeInts()
public
getRangeInts() : array<string, TIntRange>
Tags
Return values
array<string, TIntRange>getSingleAtomic()
public
getSingleAtomic() : Atomic
Tags
Return values
AtomicgetSingleFloatLiteral()
public
getSingleFloatLiteral() : TLiteralFloat
Tags
Return values
TLiteralFloat —the only float literal represented by this union type
getSingleIntLiteral()
public
getSingleIntLiteral() : TLiteralInt
Tags
Return values
TLiteralInt —the only int literal represented by this union type
getSingleLiteral()
public
getSingleLiteral() : TLiteralInt|TLiteralString|TLiteralFloat
Tags
Return values
TLiteralInt|TLiteralString|TLiteralFloatgetSingleStringLiteral()
public
getSingleStringLiteral() : TLiteralString
Tags
Return values
TLiteralString —the only string literal represented by this union type
getTemplateTypes()
public
getTemplateTypes() : array<int, TTemplateParam>
Tags
Return values
array<int, TTemplateParam>hasArray()
public
hasArray() : bool
Tags
Return values
boolhasArrayAccessInterface()
public
hasArrayAccessInterface(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Tags
Return values
boolhasArrayKey()
public
hasArrayKey() : bool
Tags
Return values
boolhasBool()
public
hasBool() : bool
Tags
Return values
boolhasCallableType()
public
hasCallableType() : bool
Tags
Return values
boolhasClassStringMap()
public
hasClassStringMap() : bool
Tags
Return values
boolhasConditional()
public
hasConditional() : bool
Tags
Return values
boolhasFloat()
public
hasFloat() : bool
Tags
Return values
boolhasInt()
public
hasInt() : bool
Tags
Return values
boolhasIterable()
public
hasIterable() : bool
Tags
Return values
boolhasList()
public
hasList() : bool
Tags
Return values
boolhasLiteralClassString()
public
hasLiteralClassString() : bool
Tags
Return values
boolhasLiteralFloat()
public
hasLiteralFloat() : bool
Tags
Return values
boolhasLiteralInt()
public
hasLiteralInt() : bool
Tags
Return values
boolhasLiteralString()
public
hasLiteralString() : bool
Tags
Return values
boolhasLiteralValue()
public
hasLiteralValue() : bool
Tags
Return values
boolhasLowercaseString()
public
hasLowercaseString() : bool
Tags
Return values
boolhasMixed()
public
hasMixed() : bool
Tags
Return values
boolhasNamedObjectType()
public
hasNamedObjectType() : bool
Tags
Return values
boolhasNull()
public
hasNull() : bool
Tags
Return values
boolhasNumeric()
public
hasNumeric() : bool
Tags
Return values
boolhasObject()
public
hasObject() : bool
Tags
Return values
boolhasObjectType()
public
hasObjectType() : bool
Tags
Return values
boolhasScalar()
public
hasScalar() : bool
Tags
Return values
boolhasScalarType()
public
hasScalarType() : bool
Tags
Return values
boolhasStaticObject()
public
hasStaticObject() : bool
Tags
Return values
boolhasString()
public
hasString() : bool
Tags
Return values
boolhasTemplate()
public
hasTemplate() : bool
Tags
Return values
boolhasTemplateOrStatic()
public
hasTemplateOrStatic() : bool
Tags
Return values
boolhasType()
public
hasType(string $type_string) : bool
Parameters
- $type_string : string
Tags
Return values
boolisAlwaysFalsy()
public
isAlwaysFalsy() : bool
Tags
Return values
boolisAlwaysTruthy()
public
isAlwaysTruthy() : bool
Tags
Return values
boolisArray()
public
isArray() : bool
Tags
Return values
bool —true if this is an array
isArrayKey()
public
isArrayKey() : bool
Tags
Return values
boolisBool()
public
isBool() : bool
Tags
Return values
bool —true if this is a boolean
isEmptyArray()
public
isEmptyArray() : bool
Tags
Return values
boolisEmptyMixed()
public
isEmptyMixed() : bool
Tags
Return values
boolisFalsable()
public
isFalsable() : bool
Tags
Return values
boolisFalse()
public
isFalse() : bool
Tags
Return values
boolisFloat()
public
isFloat() : bool
Tags
Return values
bool —true if this is a float
isGenerator()
public
isGenerator() : bool
Tags
Return values
boolisInt()
public
isInt([bool $check_templates = false ]) : bool
Parameters
- $check_templates : bool = false
Tags
Return values
bool —true if this is an int
isMixed()
public
isMixed([bool $check_templates = false ]) : bool
Parameters
- $check_templates : bool = false
Tags
Return values
boolisNever()
public
isNever() : bool
Tags
Return values
boolisNonEmptyString()
public
isNonEmptyString([bool $check_templates = false ]) : bool
Parameters
- $check_templates : bool = false
Tags
Return values
bool —true if this is a string
isNull()
public
isNull() : bool
Tags
Return values
boolisNullable()
public
isNullable() : bool
Tags
Return values
boolisObjectType()
public
isObjectType() : bool
Tags
Return values
boolisSingle()
public
isSingle() : bool
Tags
Return values
boolisSingleAndMaybeNullable()
public
isSingleAndMaybeNullable() : bool
Tags
Return values
boolisSingleFloatLiteral()
public
isSingleFloatLiteral() : bool
Tags
Return values
bool —true if this is a float literal with only one possible value
isSingleIntLiteral()
public
isSingleIntLiteral() : bool
Tags
Return values
bool —true if this is an int literal with only one possible value
isSingleLiteral()
public
isSingleLiteral() : bool
Tags
Return values
boolisSingleStringLiteral()
public
isSingleStringLiteral() : bool
Tags
Return values
bool —true if this is a string literal with only one possible value
isStaticObject()
public
isStaticObject() : bool
Tags
Return values
boolisString()
public
isString([bool $check_templates = false ]) : bool
Parameters
- $check_templates : bool = false
Tags
Return values
bool —true if this is a string
isTemplatedClassString()
public
isTemplatedClassString() : bool
Tags
Return values
boolisTrue()
public
isTrue() : bool
Tags
Return values
boolisUnionEmpty()
public
isUnionEmpty() : bool
Tags
Return values
boolisVanillaMixed()
public
isVanillaMixed() : bool
Tags
Return values
boolisVoid()
public
isVoid() : bool
Tags
Return values
boolqueueClassLikesForScanning()
public
queueClassLikesForScanning(Codebase $codebase[, FileStorage|null $file_storage = null ][, array<string, mixed> $phantom_classes = [] ]) : void
Parameters
- $codebase : Codebase
- $file_storage : FileStorage|null = null
- $phantom_classes : array<string, mixed> = []
removeType()
public
removeType(string $type_string) : bool
Parameters
- $type_string : string
Tags
Return values
boolreplaceClassLike()
public
replaceClassLike(string $old, string $new) : static
Parameters
- $old : string
- $new : string
Return values
staticsetFromDocblock()
public
setFromDocblock([bool $fromDocblock = true ]) : self
Parameters
- $fromDocblock : bool = true
Return values
selfsetTypes()
public
setTypes(array<string|int, mixed> $types) : self
Parameters
- $types : array<string|int, mixed>
Tags
Return values
selfsubstitute()
public
substitute(Union|MutableUnion $old_type[, Union|MutableUnion|null $new_type = null ]) : self
Parameters
- $old_type : Union|MutableUnion
- $new_type : Union|MutableUnion|null = null
Tags
Return values
selftoNamespacedString()
public
toNamespacedString(string|null $namespace, array<lowercase-string, string> $aliased_classes, string|null $this_class, bool $use_phpdoc_format) : string
Parameters
- $namespace : string|null
- $aliased_classes : array<lowercase-string, string>
- $this_class : string|null
- $use_phpdoc_format : bool
Tags
Return values
stringtoPhpString()
public
toPhpString(string|null $namespace, array<lowercase-string, string> $aliased_classes, string|null $this_class, int $analysis_php_version_id) : string|null
Parameters
- $namespace : string|null
- $aliased_classes : array<lowercase-string, string>
- $this_class : string|null
- $analysis_php_version_id : int
Tags
Return values
string|nullvisit()
public
visit(TypeVisitor $visitor) : bool
Parameters
- $visitor : TypeVisitor
Return values
boolvisitMutable()
public
static visitMutable(MutableTypeVisitor $visitor, mixed &$node, bool $cloned) : bool
Parameters
- $visitor : MutableTypeVisitor
- $node : mixed
- $cloned : bool