Professional Documents
Culture Documents
PHP8 - What's New in PHP8? Cheat Sheet: by Via
PHP8 - What's New in PHP8? Cheat Sheet: by Via
Cheat Sheet
by Dave Child (DaveChild) via cheatography.com/1/cs/27364/
Class/int‐ An instance of the class or public function foo(Foo|Bar public int $amount,
erface name interface $input): int|float; ) {}
self The same class the type is You can now specify more than one type in
}
used in a type hint: In the above example Currency and int
parent The parent of the class the • The void type cannot be part of a union. are both automatically made public
type is used in • Unions can be nullable by including null properties of the class and assigned values
callable Something callable as a type or preceding with a question on construction.
mark.
bool A boolean
Weak maps
int An integer
Named arguments
class Foo
float A float
function foo(string $a, int $b, {
string A string
?string $c = null) private WeakMap $cache;
array An array {
iterable Array or traversable ... public function getSometh‐
object An object } ingWithCaching(object $obj):