Run Time 3:09Free
Before we can toy around with the new additions to PHP 7.1, we must first install it. In the past, this was always a pain in the neck to accomplish; however, these days, we only need to pull in Rasmus' Vagrant image to get up and running as quickly as possible.
Run Time 4:30Free
First up, we have symmetric array destructuring: an incredibly confusing term for a simple concept: we can now use the short array syntax to translate (or destructure) any array - both indexed and associative - into a list of variables.
Run Time 6:18Free
Nullable and void types are both new to PHP 7.1. Should you desire to, you may now mark a typehint or return type as being nullable, simply by prefixing it with a question mark. This indicates that you expect either the given type, or null. Additionally, the ability to specify a void return type is now available.
Run Time 2:11Free
Often, you'll find yourself catching and responding to multiple exception types with the exact same logic. In PHP 7.1, however, you may now remove this duplication by separating each exception type with a pipe (
catch (ChargeFailed | InsufficientFunds $e)).
Run Time 3:49Free
New to PHP 7.1 is a new
iterable pseudo-type. If you're currently type-hinting
array all over the place, think about it: would you be that upset if the user instead passed an object that can be iterated over? Of course not. This new pseudo-type solves that!