On Mon, May 15, 2023 at 1:41 AM Hendra Gunawan <the.liquid.me...@gmail.com> wrote:
> 2. The shorthand notations supported (the shortest one) creates > impaired syntax, and not pretty to look at for constructor property > promotion. > It's starting to get crowded in object constructors. The following example is so much more readable and maintainable imo. Would it be possible to still add the quick assignment as a language feature? I'm personally not happy having property definitions in both the class body _and_ the constructor signature. ```php class User { private string $first; private string $last; public string $fullName { get => $this->first . ' ' . $this->last; set => [$this->first, $this->last] = explode(' ', $value, 2); } public function __construct($this->fullName) {} } // vs class User { private string $first; private string $last; public function __construct( public string $fullName { get => $this->first . ' ' . $this->last; set => [$this->first, $this->last] = explode(' ', $value, 2); } ) {} } // or class User { private string $first; private string $last; public string $fullName { get => $this->first . ' ' . $this->last; set => [$this->first, $this->last] = explode(' ', $value, 2); } public function __construct(string $fullName) { $this->fullName = $fullName; } } ```