One of my favorite PHP 8 features is constructor property promotion. It cleans up a lot of boilerplate code and makes classes easier to read.
But one place I won't use this handy feature is if I need to possibly override the value inside the constructor. For example, maybe the constructor allows a null value to be passed in, but I might initialize it to a different value.
In those cases, I explicitly declare the class property and set it in the constructor, just like the pre-PHP 8 days. It's a small change, but it seems clearer to me.
Here to help,
Joel
P.S. If you have found this newsletter helpful and want to show your support, click the "Toss a coin" link below and give whatever you like. I really appreciate it!