ArrayType implements Type
Read onlyYes
FinalYes
Tags
Interfaces
Methods
- assert() : array<string|int, mixed>
- Checks that the value is of the type of this object, throwing when it is not.
- cast() : array<string|int, mixed>
- Takes a value and when necessary casts it to the type of this object.
- isValid() : bool
- Checks if the value is of the type of this object, returning a boolean instead of throwing.
- normalize() : array<string, mixed>
- toString() : string
- Returns a string representation of the type.
Methods
assert()
Checks that the value is of the type of this object, throwing when it is not.
public
assert(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>cast()
Takes a value and when necessary casts it to the type of this object.
public
cast(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>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 @phpstan-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
boolnormalize()
public
normalize() : array<string, mixed>
Return values
array<string, mixed>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())