Cheatography
https://cheatography.com
Cheat sheet for PHP type hinting using Psalm (or PHPStan)
This is a draft cheat sheet. It is a work in progress and is not finished yet.
Scalar types
|
Boolean |
|
Float |
|
String |
|
Integer |
|
Range of integers -1 through 3 |
|
|
|
|
|
Bitmask combination of its parameters (corresponds to 0|1|2|3|4|5|6|7
) |
int-mask-of<Class::CONSTANT_*>
|
Correspond to 0|1|2|3|4|5|6|7
if there are three constants CONSTANT_{A,B,C}
with values 1
, 2
and 4
. |
|
Supertype (not a union) of int
and string
|
|
Supertype of int
or float
or numeric-string
|
|
Expect a class string ::class
|
class-string<MyClass>
|
Expects a specific class string MyClass::class
|
|
Similar to class-string, but expects interface(s) |
|
Similar to class-string, but expects trait(s) |
|
Similar to class-string, but expects enum(s) |
|
Denotes a string value that has passed an is_callable
check |
|
Denotes a string value that has passed an is_numeric check |
|
Denotes a string value that is entirely composed of strings |
|
Denotes an int value that is entirely composed of literal integers in your application |
|
Lowercase string |
|
String that is not empty |
non-empty-lowercase-string
|
String that is not empty AND lowercase |
|
Property declaration types
|
Indicates property is a string or null |
|
Indicates variable $a is a string |
|
Param $s is "a" or "b" |
@param A::FOO | A::BAR $s
|
Param $s is const A::FOO
or A::BAR
|
|
Param $s is any const of A
prefixed with STATUS_
|
|
|
|
|
|