While I wasn’t paying attention, PHP got quite good
The last time I've used PHP was probably around 2017, although it was just in the context of supporting some WordPress sites. By that time 7.2 had already been released, but I had no idea. I wanted to avoid working with PHP at all costs.
This month I took some time to check what good things have been added to the language that I was unaware of. To be honest, things are looking great.
The list below is not exhaustive, I only reference what I’ll be using, or find notable.
Support for string-keyed (associative) arrays in v8.1
Match expressions
Added in v8.1
The one thing I’m most jealous it’s missing in JavaScript
Enumerations (enums)
Added in v8.1
Arrow functions
Added in v7.4
fn (args) => expression
(!) Arrow functions can’t be multi-line
Named parameters
Added in v8.0
Null coalescing operator
Added in v7.0
Null coalescing assignment operator
Added in v7.4
Null-safe operator
Added in v8.0
Spaceship operator
Added in v7.0
Multi-catch exception handling
Added in v7.1
New string utils
Added in v8.0
Previously we would use strpos or some other creative solution.
Return types
Added in v7.0
Union types
Added in v8.0
Null and Void return types
Added in v7.1
Never return type
Added in v8.1
Import grouping
Added in v7.0
A small but welcome addition
Constructor property promotion
Added in v8.0
Weakmaps
Not really using Weakmaps, not even in JavaScript, but I find it a great addition
I have to say I’m very happy to see these features, and I look forward to the next PHP releases with great excitement. Although I’ll be mostly working with Laravel and its extensive library (collections & helpers) watching the language grow is lovely.