Source: stitcher.io

Property promotion in PHP 8

Category: PHP

If you enjoy reading my blog, you could consider supporting me on Patreon. Personally, I use value objects and data transfer objects all the time in my projects.

Naturally, I'm very happy with the constructor property promotion RFC, it's passed and will be added in PHP 8.

In short: property promotion allows you to combine class fields, constructor definition and variable assignments all into one syntax, in the construct parameter list.

You're not able to declare a class property and a promoted property with the same name.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners