Complete the code to declare a promoted property in the constructor.
<?php class User { public function __construct(private [1] $name) {} }
int or bool for a text property.The constructor promotion syntax requires the type before the property name. Here, string is the correct type for the $name property.
Complete the code to promote two properties in the constructor.
<?php class Product { public function __construct(private string $name, private [1] $price) {} }
int which only holds whole numbers.string for numeric values.The $price property should hold decimal numbers, so float is the correct type.
Fix the error in the constructor promotion syntax.
<?php class Order { public function __construct(private [1] $id, private int $quantity) {} }
string for numeric IDs.The $id property should be an integer, so int is the correct type to fix the error.
Fill both blanks to promote properties with correct types.
<?php class Employee { public function __construct(private [1] $name, private [2] $active) {} }
The $name is text, so string is correct. The $active is a true/false value, so bool is correct.
Fill all three blanks to promote properties with correct types and visibility.
<?php class Book { public function __construct([1] string $title, private [2] $pages, protected [3] $available) {} }
$title.$pages or $available.The $title property is private, so private is correct. The $pages is a number, so int is correct. The $available is true/false, so bool is correct.