May 16, 2020

PHP has had type hints and type declarations for several versions, but they haven't really been available in all contexts. Class-based type hints on method parameters arrived in PHP 5.x, and PHP 7.0 added Scalar type declarations. You can set a type on a method parameter, or specify a return type, but in PHP 7.4 we got something really fun: Now you can declare a type on a class property.

May 3, 2020

Arrow Functions are a new syntax for short anonymous functions introduced in PHP 7.4.

Anonymous functions, if you're not familiar with them, are special functions written inside other sections of your code that you can pass around kind of like variables.

Usually these functions are very short and purpose-built. They're not supposed to contain a huge amount of logic.

Where arrow functions stand out is that they allow you to write concise single-operation anonymous functions like you might use when doing sorting or map/reduce operations.

April 21, 2020

PHP 7 and 8 are huge leaps forward for the language. Gone are the days of hacking together an entire web application in a single file (although you can technically still do that, if you're feeling retro). Now there are so many fancy new language features that you might find yourself adrift in the sea of changes.

I'd like to introduce some of these new features one at a time, to give them a chance to catch your attention and capture your imagination.

Today's subject: the Null Coalesce operator, a little ditty from PHP 7.0 that looks like ??.