Re:Modern PHP features explained – PHP 8.0 and 8.1
by mrcarrot on Thursday October 27, 2022 @11:20AM
(#33358896)
> And what if I don't want to have my constructor parameters as properties, maybe because I process them somehow in the constructor, and set some other properties instead?
Then you don't use property promotion. It's optional: it only happens if you add a visibility modifier before the parameter name.
Then you don't use property promotion. It's optional: it only happens if you add a visibility modifier before the parameter name.