Re: Method parameter promotion support

From: Date: Thu, 26 Nov 2020 17:27:00 +0000
Subject: Re: Method parameter promotion support
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-112303@lists.php.net to get a copy of this message
On Thu, Nov 26, 2020 at 10:43 AM Pierre R. <pierre-php@processus.org> wrote: > Le 26/11/2020 à 17:30, David Rodrigues a écrit : > > It is just an idea to discuss. PHP 8 now supports parameter promotion via > > constructor. Could this idea also work for common methods? > > > > public function setAge(private int $age) {} > > === > > private int $age; > > public function setAge(int $age) { $this->age = $age; } > > It sounds weird for me, Same. I'd also add that for solving this problem (boilerplate accessors), I'd much rather see us adopt C# like accessor methods and/or offer something like the expressive methods that Larry suggested a couple weeks ago. Both of those have a more generalized path to addressing this, IMO. -Sara

« previous php.internals (#112303) next »