![]() Maybe the developer who wrote the code doesn't yet know that the promoted properties exist, maybe he doesn't want to use this feature, or maybe his code was written before the arrival of PHP 8. If none of the properties are promoted, that doesn't necessarily mean that all properties of that constructor are special cases. It makes the code smarter, but it also makes the reading of the code smarter by indicating the points of attention to be had.Īnd as it is contextual, as you can imagine, the reasoning that I have just described will not work every time. ![]() Or, like in our example, maybe it needed to pass it to the parent class. Perhaps he had particular tests to do on this property. It's contextual: since the developer who wrote the code used promoted properties, why didn't he promote all the properties? Probably because he had no choice. In the example above, did you notice the $desc property? We don't use constructor property promotion for it, which gives me another piece of information: $desc is not a classic case of an instance variable, the developer had to do something else with it, and it might be interesting to watch what it's all about. ![]()
0 Comments
Leave a Reply. |