Re: [RFC[ Property accessor hooks, take 2

From: Date: Mon, 26 Feb 2024 08:53:35 +0000
Subject: Re: [RFC[ Property accessor hooks, take 2
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-122492@lists.php.net to get a copy of this message
On Thu, 22 Feb 2024, at 23:56, Larry Garfield wrote: > However, I just had a long discussion with Ilija and there is one > possibility we could consider: Use the return value only on the > shorthand (arrow-function-like) syntax. > > So you could do either of these, which would be equivalent: > > set { > $this->phone = $this->santizePhone($value); > } > > set => $this->santizePhone($value); Regarding this point, I've realised that the current short-hand set syntax isn't actually any shorter: set { $this->phone = $this->santizePhone($value); } set => $this->phone = $this->santizePhone($value); It also feels weird to say both "the right-hand side must be a valid expression" and "the value of the expression is ignored". So I think making the short-hand be "expression to assign to the implicit backing field" makes a lot more sense. Regards, -- Rowan Tommins [IMSoP]

« previous php.internals (#122492) next »