Flow PHP

MapType implements Type

Read onlyYes
FinalYes
Tags
template-covariant

of array-key

Interfaces

Type

Methods

__construct()  : mixed
assert()  : T
Checks that the value is of the type of this object, throwing when it is not.
cast()  : T
Takes a value and when necessary casts it to the type of this object.
fromArray()  : MapType<string|int, mixed>
isValid()  : bool
Checks if the value is of the type of this object, returning a boolean instead of throwing.
key()  : Type<string|int, TKey>
normalize()  : array{type: "map", key: array, value: array}
toString()  : string
Returns a string representation of the type.
value()  : Type<string|int, TValue>

Methods

__construct()

public __construct(Type<string|int, TKey> $key, Type<string|int, TValue> $value) : mixed
Parameters
$key : Type<string|int, TKey>
$value : Type<string|int, TValue>

assert()

Checks that the value is of the type of this object, throwing when it is not.

public assert(mixed $value) : T
Parameters
$value : mixed
Return values
T

cast()

Takes a value and when necessary casts it to the type of this object.

public cast(mixed $value) : T
Parameters
$value : mixed
Return values
T

isValid()

Checks if the value is of the type of this object, returning a boolean instead of throwing.

public isValid(mixed $value) : bool

When this method returns true, static analysis tools narrow the value's type to T at the call site (via @assert-if-true). Use this when you want to branch on the result; use assert() when you want the call to fail loudly on a mismatch.

Parameters
$value : mixed
Return values
bool

key()

public key() : Type<string|int, TKey>
Return values
Type<string|int, TKey>

normalize()

public normalize() : array{type: "map", key: array, value: array}
Return values
array{type: "map", key: array, value: array}

toString()

Returns a string representation of the type.

public toString() : string
  • string - for type_string()
  • int - for type_int()
  • ?float - for type_optional(type_float())
Return values
string

value()

public value() : Type<string|int, TValue>
Return values
Type<string|int, TValue>
On this page

Search results