PHP 8.0 feature focus: Constructor Property Promotion
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:
Comments are closed.