PHP 8.0 feature focus: <span>Constructor Property Promotion</span>
syndicated from planet-php.net
on November 4, 2020
The last post talked about how PHP 8.0 makes PHP faster. Today, we’ll look at a way that it will make you faster. Perhaps the largest quality-of-life improvement to PHP 8.0 is Constructor Property Promotion. The syntax has been borrowed largely from Hack, Facebook’s PHP fork, although it exists in other languages like TypeScript and Kotlin with various syntaxes. It’s easiest to explain with an example. Consider your typical service class in a modern application: