If you enjoy reading my blog, you could consider supporting me on Patreon.

New in PHP 7.4

PHP 7.4 will probably be released somewhere December 2019. This page will receive regular updates meanwhile.

# Preloading rfc

Preloading is an amazing addition to PHP's core, which can result in some major performance improvements.

In short: if you're using a framework today, its files have to be loaded and recompiled on every request. Preloading allows the server to load PHP files in memory on startup, and have them permanently available to all subsequent requests.

The performance gain comes of course with a cost: if the source of preloaded files are changed, the server has to be restarted.

# Typed properties rfc

Class variables can be type hinted:

class A
    public string $name;
    public Foo $foo;

Update 07-01: As of now, typed properties are merged, and thus confirmed for PHP 7.4.

# Improved type variance rfc

I wrote about PHP's type system in the past, so it's good to see some improvements are actually arriving in PHP's core.

Type variance is a topic worth its own blog post; in short: you'll be able use covariant return types…

class ParentType {}
class ChildType extends ParentType {}

class A
    public function covariantReturnTypes(): ParentType
    { /* … */ }

class B extends A
    public function covariantReturnTypes(): ChildType
    { /* … */ }

… and contravariant arguments.

class A
    public function contraVariantArguments(ChildType $type)
    { /* … */ }

class B extends A
    public function contraVariantArguments(ParentType $type)
    { /* … */ }

Update 14-01: The RFC is currently in the voting phase, but it looks like it'll pass without any problems.

This is where the ad would go. I get it, they are stupid. But to be honest, they actually make a difference. So maybe you'd consider whitelisting this blog or support me on Patreon?

# Foreign function interface rfc

Foreign Function Interface, FFI in short, allows calling C code from userland. This means that PHP extensions can be written in pure PHP.

It should be noted that this is a complex topic. You still need C knowledge to be able to correctly use this feature.

# Null coalescing assignment operator rfc

Instead of doing this:

$data['date'] = $data['date'] ?? new DateTime();

You can do this:

$data['date'] ??= new DateTime();

Update 22-01: this feature is now merged in PHP 7.4.

# Custom object serialization rfc

This RFC adds two new magic methods: __serialize and __unserialize. The difference between these methods and __sleep and __wakeup is discussed in the RFC.

Update 04-21: the RFC passed. This feature will be added in PHP 7.4.

# No more narrow margins rfc

Technically not an update related to PHP 7.4, though it's definitely worth mentioning. The voting rules for RFC's have been changed: they always need a 2/3 majority in order to pass.

# Reflection for references rfc

Libraries like Symfony's var dumper rely heavily on the reflection API to reliably dump a variable. Previously, no proper reflection support for references was available, causing these libraries to rely on hacks to detect references.

PHP 7.4 adds the ReflectionReference class which solves this issue.

Update 02-14: the RFC has passed and the changes are confirmed for PHP 7.4.

# mb_str_split added RFC

This function provides the same functionality as str_split, but on multi byte strings.

# ext-hash always enabled rfc

As the title says, this extension is now permanently available in all PHP installations.

# PEAR not enabled by default EXTERNALS

Because PEAR isn't actively maintained anymore, the core team decided to remove its default installation with PHP 7.4.

# Password Hashing Registry RFC

Internal changes to how hashing libraries are used, so that it's easier for userland to use them.

# Deprecate ext/wwdx RFC

This data exchange format was never standardised, and now its extension is deprecated.

This is where the ad would go. I get it, they are stupid. But to be honest, they actually make a difference. So maybe you'd consider whitelisting this blog or support me on Patreon?

# Backward incompatible changes UPGRADING

You should always take a look at the full UPGRADING document when upgrading PHP versions.

Here are some of the backward incompatible changes highlighted:

# Hang on now…

If you've made it this far, chances are you are interested in PHP. Maybe you're also interested in reading my other content? Here are some of the things I wrote.

Oh and lastly, follow me on Twitter if you want to stay up to date!