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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners