You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You have been given a piece of code (look for `php-gets-a-promotionn.php` in your working directory) which provides a class written for PHP 7.
2
-
The code itself works well assigning constructor arguments to the class properties. Your job is to write the code in a more terse format, by using the newly introduced
1
+
You have been given a piece of code (look for `php-gets-a-promotion.php` in your working directory) which provides a class written for PHP 7.
2
+
The code itself works well, assigning constructor arguments to the class properties. Your job is to write the code in a more terse format, by using the newly introduced
3
3
constructor property promotion in PHP 8.
4
4
5
-
The code is a class is one that would hypothetically be used to call a provided `\Closure` when reading a row of a CSV, passing in the appropriate cell value, but the implementation logic is not important and thus left out.
5
+
The code is a class that would hypothetically be used to call a provided `\Closure` when reading a row of a CSV, passing in the appropriate cell value, but the implementation logic is not important and thus left out.
6
6
7
-
Focus on converting the constructor to a terse format using constructor propery promotion.
7
+
Focus on converting the constructor to a terse format using constructor property promotion.
8
8
9
9
### The advantages of constructor property promotion
10
10
11
11
* Less boilerplate code is required when writing a class
12
-
*Still provides the required information for static analysis / runtime type parsing
13
-
* Is compatible in conjuction with properties that cannot be promoted
12
+
*It still provides the required information for static analysis / runtime type parsing
13
+
* Is compatible in conjunction with properties that cannot be promoted
0 commit comments