PHP 7.4 is coming! A quick overview.

PHP 7.4 is on its way, with an unconfirmed final release date in December 2019.

This update brings about some long awaited changes, though still lacks Generics.

Typed Properties

Typed method parameters and method return types already exist. But in PHP 7.4 there will finally be typed properties.

This means you can ensure properties of a class are of a certain type, enforcing stricter controls which can result in more stable scripts and libraries.


class Example
    public int $thisIsAnInt;
    public bool $thisIsABool;
    public Foo $thisIsAnInstanceOfFoo;
    public ?float $thisIsAFloatOrNull;
    public ?string $thisIsAStringOrNull;

Read the RFC

Null Coalescing Assignment Operator

Already you can use the Null coalescing operator:

$example = $thisIsNull ?? $thisIsNotNull;

$example will take the value of $thisIsNotNull when $thisIsNull is Null, otherwise it will take the value of $thisIsNull.

But with the Null Coalescing Assignment Operator, you'll be able to do this:

$thisMightBeNull ??= $thisIsNotNull

Which means: If $thisMightBeNull is Null, then set to $thisIsNotNull. Otherwise keep the same value.

Read the RFC

Custom object serialization mechanism

Addition of the new magic methods for classes, __serialize() and __unserialize().

Read the RFC


Multi-byte string splitting will be introduced. This is good news for those working with languages such as Arabic and Asian scripts.

Read the RFC

Breaking changes

There are a few changes that could break older scripts. Most of these look like they shouldn't affect well-written scripts but it is something to be aware of.

Read on GitHub

Written by Kieran on 2019-04-21
This website uses Cookies to enhance your experience. Close Manage