As promised by the PHP release team, PHP 7.3.0 was released on schedule as a nice present for St Nicolas' Day. I have been testing the release candidates with Neos and Flow during the last couple of weeks. How did it go?

What’s New In PHP 7.3?

The new features probably won't knock your socks off. However, alone the fact that the PHP team managed to keep a steady (and much more frequent) release cycle, is reason to celebrate. It definitely shows that PHP has gained speed again and that you can plan with new releases.

As for the actual changes, there are a few I'd like to highlight:

References Support in list()

The good old list() function allows you to assign variables from a given array. This comes in handy, if you need to pass multiple return values from a function call, fore example. What's new in PHP 7.3 is, that the variables used in list() can be assigned by reference.

Consider this:

$array = ['PHP 5.6', 'PHP 7.0'];
list(&$a, $b) = $array;
$a = 'PHP 7.3';
echo $array[0];

A great way to get rid of PHP 5.6, isn't it?

Deprecated: Case-Insensitive Constant Names

Did you know that define() had a third parameter? Setting it to true allows you to state that the constant name you are declaring is case-insensitive. While declaring constants with the const keyword is case-insensitive, the default for define() was case-sensitive. Now with PHP 7.3, you'll get a deprecation warning if you try to access the constant by any other than the originally defined name.

JsonException

Working with the original JSON-functions in PHP was a bit error-prone. Because, if something went wrong, these functions were pretty silent.

Starting with PHP 7.3, json_encode() and json_decode() can now throw an exception:

try {
  json_decode("🍌", false, 512, JSON_THROW_ON_ERROR);
}
catch (\JsonException $exception) {
  echo $exception->getMessage(); # Will display "syntax error". 🚀
}

array_key_first() and array_key_last()

Maybe it's a while that you though: "if only PHP had more array functions!". But even though there are plenty of them already, I think that these two additions will come in handy.

As the name suggests, these functions allow you to retrieve the first or the last key of an array respectively. What's nice about it is, that some other array functions you might have used for that task, require the array being passed by reference. Not so with array_key_first() and array_key_last()!

Running Neos on PHP 7.3

Can't wait to try out PHP 7.3.0 with Neos? As far as I can tell, it works really well - no adjustments necessary. In fact, this very website is already running on the new version!

Is your hoster still running antiquated PHP versions? Maybe 5.6 even? Then it's time to find a new one. And if you need a home for a Neos site or Flow application, did you know we created a cloud platform perfectly made for your favorite CMS? Just give it try, we'd be happy to welcome you at the Beach!

Neos using PHP 7.3 on Flownative Beach