Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:65113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 88072 invoked from network); 23 Jan 2013 14:03:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Jan 2013 14:03:56 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.43 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.212.43 mail-vb0-f43.google.com Received: from [209.85.212.43] ([209.85.212.43:53149] helo=mail-vb0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/62-01592-BCDEFF05 for ; Wed, 23 Jan 2013 09:03:56 -0500 Received: by mail-vb0-f43.google.com with SMTP id fr13so1944755vbb.16 for ; Wed, 23 Jan 2013 06:03:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=ESY/5yxN68QIkNj7xun+H0HSyWQhumPFLHI3EwKDK7I=; b=zHUYiSwZcz9egorOfPBlkz0C84UoODUEqW6v2i+LFkMCh8yt1yJ22zRbP05zOhcqAT 7i9GibcdZeJTc36XMajDnExg5qHBRMbcmWnRd4POoTNX9hgbIJTPoFyZ0dV0uu0k+e8K Oh3443KRlAFrWhRurioj3Fm1iIGXtaW6oJO6+qcTZ0CPWWouqQXQpDMz4LF7Lrdj3r5G wlUpXjK+cX50hm21+zZoDFqQsewUX5kjpsPWoqfu6ha/4PBneJ5+U/z9LYDwqac3YmIZ /Md0EQgl08ZHPo5ztbBSR5+Xg6X3poa3XwFAS2n7+1/Cn+kpFEWY+2kAuw3g/h5KE5S4 eB2g== MIME-Version: 1.0 X-Received: by 10.220.153.143 with SMTP id k15mr1397353vcw.13.1358949833445; Wed, 23 Jan 2013 06:03:53 -0800 (PST) Received: by 10.58.173.4 with HTTP; Wed, 23 Jan 2013 06:03:53 -0800 (PST) In-Reply-To: References: <50F840F4.7080704@zerocue.com> <50FE7579.1010409@zerocue.com> Date: Wed, 23 Jan 2013 09:03:53 -0500 Message-ID: To: Sherif Ramadan Cc: Clint Priest , PHP Developers Mailing List Content-Type: multipart/alternative; boundary=f46d043d6771170fa404d3f52ac8 Subject: Re: [PHP-DEV] [VOTE] Property Accessors for 5.5 From: ircmaxell@gmail.com (Anthony Ferrara) --f46d043d6771170fa404d3f52ac8 Content-Type: text/plain; charset=ISO-8859-1 Sherif, Don't get me wrong, I liked it, but I also disliked the fact that it > introduces language changes that aren't easy to grasp or document. To me > this means we've borderline changed the behavior of a property (which most > PHP users currently understand to be a variable) into potential methods. > This is basically saying we can now completely change the behavior of a > property from a storage unit to a functional unit. That's a bit of a scary > thought to me, because it makes me question everything I know about > properties in PHP. > Except that everything that's proposed here is possible today with __get, __set, __isset and __unset. So already today you can't assume that a property is a "variable". In fact, you could build something like this using __get, etc extremely dirty: class Foo { public function __get($name) { $method = 'get' . ucfirst($name); if (method_exists($this, $method)) { return $this->method(); } return $this->$name; // public properties } public function __set($name, $value) { $method = 'set' . ucfirst($name); if (method_exists($this, $method)) { return $this->method($value); } return $this->$name = $value; // public properties } } The difference in functionality that this provides is the ability to custom-scope getters and setters. And it's a LOT cleaner... Anthony --f46d043d6771170fa404d3f52ac8--