What is Constructor Property Promotion in PHP 8, and how does it change class definitions?

Last updated 15 June 2026

  • Constructor Property Promotion (PHP 8) lets you declare and assign a property directly in the constructor signature by adding a visibility modifier (public, protected, private, or readonly) to a parameter.

  • It removes boilerplate: no separate property declarations and no $this->x = $x; lines, which is ideal for data/value objects.

  • Limits: it only works in the constructor, can't promote callable params, and can't duplicate a property declared elsewhere. A constructor body for validation is still allowed.

  • https://www.tutorialspoint.com/article/constructor-property-promotion-in-php-8
All PHP interview questions