Re: [RFC] Property hooks, nee accessors

From: Date: Mon, 15 May 2023 09:15:42 +0000
Subject: Re: [RFC] Property hooks, nee accessors
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-120282@lists.php.net to get a copy of this message
> ```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) {} > } > ``` Not entirely true, you created redundancy code for ``$fullName``. This is why we created constructor property promotion: to eliminate redundancy.

« previous php.internals (#120282) next »