PHP types are good for enforcing types at runtime, however they currently do not provide the "full story" regarding the data shape. The best example of this is the array
type. It is common that PHPDoc will be used to better describe the array contents, e.g.;
string[]
- Array of string
(string|string[])[]
- Array of string
and string[]
[int, string][]
- Array of int
and string
tuples (array of arrays), not sure about the syntax here
string[][]
- Array of string[]
.
Less frequently used syntax the expands type hinting to array indexes;
string[int]
- Array of string
where indexes are all int
(useful when indexes will be used later on)