TKeyedArray
extends Atomic
in package
uses
UnserializeMemoryUsageSuppressionTrait
Represents an 'object-like array' - an array with known keys.
Tags
Table of Contents
Constants
- NAME_ARRAY = 'array'
- NAME_LIST = 'list'
Properties
- $checked : bool
- Whether or not the type has been checked yet
- $class_strings : array<string|int, mixed>|null
- $fallback_params : Union}|null
- If the shape has fallback params then they are here
- $from_docblock : bool
- Whether or not the type comes from a docblock
- $is_list : bool
- $offset_end : int|null
- $offset_start : int|null
- $properties : array<string|int, mixed>
- $text : string|null
Methods
- __construct() : mixed
- Constructs a new instance of a generic type
- __toString() : string
- __unserialize() : void
- allShapeKeysAlwaysDefined() : bool
- Whether all keys are always defined (ignores unsealedness).
- canBeFullyExpressedInPhp() : bool
- create() : Atomic
- equals() : bool
- getAssertionString() : string
- This string is used in order to transform a type into an string assertion for the assertion module Default to self::getId()
- getGenericArrayType() : TArray|TNonEmptyArray
- getGenericKeyType() : Union
- getGenericValueType() : Union
- getId() : string
- This is the true identifier for the type. It defaults to self::getKey() but can be overridden to be more precise
- getIterable() : TIterable
- getKey() : string
- This is the string that will be used to represent the type in Union::$types. This means that two types sharing the same getKey value will override themselves in a Union
- getMaxCount() : int<1, max>|null
- Returns null if there is no upper limit.
- getMinCount() : int<0, max>
- hasArrayAccessInterface() : bool
- hasCountableInterface() : bool
- hasTraversableInterface() : bool
- isArrayAccessibleWithIntOrStringKey() : bool
- isArrayAccessibleWithStringKey() : bool
- isCallableType() : bool
- isCountable() : bool
- isFalsy() : bool
- isGenericList() : bool
- isIterable() : bool
- isNamedObjectType() : bool
- isNonEmpty() : bool
- isNumericType() : bool
- isObjectType() : bool
- isSealed() : bool
- isTruthy() : bool
- makeSealed() : static
- replaceClassLike() : static
- replaceTemplateTypesWithArgTypes() : static
- replaceTemplateTypesWithStandins() : static
- setFromDocblock() : static
- setProperties() : static
- toNamespacedString() : string
- Returns the detailed description of the type, either in phpdoc standard format or Psalm format depending on flag Default to self::getKey()
- toPhpString() : string
- Returns a string representation of the type compatible with php signature or null if the type can't be expressed with the given php version
- visit() : bool
- visitMutable() : bool
- __clone() : mixed
- getChildNodeKeys() : array<int, string>
- escapeAndQuote() : string|int
Constants
NAME_ARRAY
protected
non-empty-lowercase-string
NAME_ARRAY
= 'array'
NAME_LIST
protected
non-empty-lowercase-string
NAME_LIST
= 'list'
Properties
$checked
Whether or not the type has been checked yet
public
bool
$checked
= false
$class_strings
public
array<string|int, mixed>|null
$class_strings
= null
$fallback_params
If the shape has fallback params then they are here
public
Union}|null
$fallback_params
= null
$from_docblock
Whether or not the type comes from a docblock
public
bool
$from_docblock
= false
$is_list
public
bool
$is_list
= false
- if this is a list of sequential elements
$offset_end
public
int|null
$offset_end
= null
$offset_start
public
int|null
$offset_start
= null
$properties
public
array<string|int, mixed>
$properties
$text
public
string|null
$text
= null
Methods
__construct()
Constructs a new instance of a generic type
public
__construct(array<string|int, mixed> $properties[, array<string, bool> $class_strings = null ][, Union}|null $fallback_params = null ][, bool $is_list = false ][, bool $from_docblock = false ]) : mixed
Parameters
- $properties : array<string|int, mixed>
- $class_strings : array<string, bool> = null
- $fallback_params : Union}|null = null
- $is_list : bool = false
- $from_docblock : bool = false
__toString()
public
final __toString() : string
Return values
string__unserialize()
public
__unserialize(array<string|int, mixed> $properties) : void
Parameters
- $properties : array<string|int, mixed>
allShapeKeysAlwaysDefined()
Whether all keys are always defined (ignores unsealedness).
public
allShapeKeysAlwaysDefined() : bool
Return values
boolcanBeFullyExpressedInPhp()
public
canBeFullyExpressedInPhp(int $analysis_php_version_id) : bool
Parameters
- $analysis_php_version_id : int
Return values
boolcreate()
public
static create(string $value[, int $analysis_php_version_id = null ][, array<string, array<string, Union>> $template_type_map = [] ][, array<string, TypeAlias> $type_aliases = [] ][, int|null $offset_start = null ][, int|null $offset_end = null ][, string|null $text = null ][, bool $from_docblock = false ]) : Atomic
Parameters
- $value : string
- $analysis_php_version_id : int = null
-
contains php version when the type comes from signature
- $template_type_map : array<string, array<string, Union>> = []
- $type_aliases : array<string, TypeAlias> = []
- $offset_start : int|null = null
- $offset_end : int|null = null
- $text : string|null = null
- $from_docblock : bool = false
Tags
Return values
Atomicequals()
public
equals(Atomic $other_type, bool $ensure_source_equality) : bool
Parameters
- $other_type : Atomic
- $ensure_source_equality : bool
Return values
boolgetAssertionString()
This string is used in order to transform a type into an string assertion for the assertion module Default to self::getId()
public
getAssertionString() : string
Return values
stringgetGenericArrayType()
public
getGenericArrayType([string|null $list_var_id = null ]) : TArray|TNonEmptyArray
Parameters
- $list_var_id : string|null = null
Return values
TArray|TNonEmptyArraygetGenericKeyType()
public
getGenericKeyType([bool $possibly_undefined = false ]) : Union
Parameters
- $possibly_undefined : bool = false
Return values
UniongetGenericValueType()
public
getGenericValueType([bool $possibly_undefined = false ]) : Union
Parameters
- $possibly_undefined : bool = false
Return values
UniongetId()
This is the true identifier for the type. It defaults to self::getKey() but can be overridden to be more precise
public
getId([bool $exact = true ][, bool $nested = false ]) : string
Parameters
- $exact : bool = true
- $nested : bool = false
Return values
stringgetIterable()
public
getIterable(Codebase $codebase) : TIterable
Parameters
- $codebase : Codebase
Tags
Return values
TIterablegetKey()
This is the string that will be used to represent the type in Union::$types. This means that two types sharing the same getKey value will override themselves in a Union
public
getKey([bool $include_extra = true ]) : string
Parameters
- $include_extra : bool = true
Return values
stringgetMaxCount()
Returns null if there is no upper limit.
public
getMaxCount() : int<1, max>|null
Return values
int<1, max>|nullgetMinCount()
public
getMinCount() : int<0, max>
Return values
int<0, max>hasArrayAccessInterface()
public
hasArrayAccessInterface(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolhasCountableInterface()
public
hasCountableInterface(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolhasTraversableInterface()
public
hasTraversableInterface(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Tags
Return values
boolisArrayAccessibleWithIntOrStringKey()
public
isArrayAccessibleWithIntOrStringKey(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolisArrayAccessibleWithStringKey()
public
isArrayAccessibleWithStringKey(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolisCallableType()
public
isCallableType() : bool
Return values
boolisCountable()
public
isCountable(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolisFalsy()
public
isFalsy() : bool
Return values
boolisGenericList()
public
isGenericList() : bool
Tags
Return values
boolisIterable()
public
isIterable(Codebase $codebase) : bool
Parameters
- $codebase : Codebase
Return values
boolisNamedObjectType()
public
isNamedObjectType() : bool
Return values
boolisNonEmpty()
public
isNonEmpty() : bool
Return values
boolisNumericType()
public
isNumericType() : bool
Return values
boolisObjectType()
public
isObjectType() : bool
Return values
boolisSealed()
public
isSealed() : bool
Return values
boolisTruthy()
public
isTruthy() : bool
Return values
boolmakeSealed()
public
makeSealed() : static
Return values
staticreplaceClassLike()
public
replaceClassLike(string $old, string $new) : static
Parameters
- $old : string
- $new : string
Return values
staticreplaceTemplateTypesWithArgTypes()
public
replaceTemplateTypesWithArgTypes(TemplateResult $template_result, Codebase|null $codebase) : static
Parameters
- $template_result : TemplateResult
- $codebase : Codebase|null
Return values
staticreplaceTemplateTypesWithStandins()
public
replaceTemplateTypesWithStandins(TemplateResult $template_result, Codebase $codebase[, StatementsAnalyzer|null $statements_analyzer = null ][, Atomic|null $input_type = null ][, int|null $input_arg_offset = null ][, string|null $calling_class = null ][, string|null $calling_function = null ][, bool $replace = true ][, bool $add_lower_bound = false ][, int $depth = 0 ]) : static
Parameters
- $template_result : TemplateResult
- $codebase : Codebase
- $statements_analyzer : StatementsAnalyzer|null = null
- $input_type : Atomic|null = null
- $input_arg_offset : int|null = null
- $calling_class : string|null = null
- $calling_function : string|null = null
- $replace : bool = true
- $add_lower_bound : bool = false
- $depth : int = 0
Return values
staticsetFromDocblock()
public
setFromDocblock(bool $from_docblock) : static
Parameters
- $from_docblock : bool
Return values
staticsetProperties()
public
setProperties(array<string|int, mixed> $properties) : static
Parameters
- $properties : array<string|int, mixed>
Return values
statictoNamespacedString()
Returns the detailed description of the type, either in phpdoc standard format or Psalm format depending on flag Default to self::getKey()
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
Return values
stringtoPhpString()
Returns a string representation of the type compatible with php signature or null if the type can't be expressed with the given php version
public
toPhpString(string|null $namespace, array<lowercase-string, string> $aliased_classes, string|null $this_class, int $analysis_php_version_id) : string
Parameters
- $namespace : string|null
- $aliased_classes : array<lowercase-string, string>
- $this_class : string|null
- $analysis_php_version_id : int
Return values
stringvisit()
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
Tags
Return values
bool__clone()
protected
__clone() : mixed
getChildNodeKeys()
protected
getChildNodeKeys() : array<int, string>
Return values
array<int, string>escapeAndQuote()
private
escapeAndQuote(string|int $name) : string|int
Parameters
- $name : string|int