RE: [PHP-DEV] RFC: Property get/set syntax

From: Date: Sun, 22 Apr 2012 03:48:27 +0000
Subject: RE: [PHP-DEV] RFC: Property get/set syntax
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-60256@lists.php.net to get a copy of this message
> -----Original Message----- > From: Stas Malyshev [mailto:smalyshev@sugarcrm.com] > Sent: Saturday, April 21, 2012 10:33 PM > To: Clint M Priest > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] RFC: Property get/set syntax > > Hi! > > > empty() - Returns true for a property retrieved via __get() or via a > > getter -- Any idea why this would be the case for __get()? Is this a > > bug? > > isset() calls __isset(), empty() calls __isset() and __get(). I'm not sure what exactly > you consider to be a bug. I see, well the only way to resolve this would be to add isset and unset property functions as well. Anyone against it? > > > unset() - Would unset a temporary variable (the one returned by the > > getter) -- see previous email re: adding unset/isset property > > functions. > > unset() calls __unset(). > > > sort() - Does the same thing as with __get()/__set() which is to say, > > the array is sorted but the property is not updated with the value. > > Should accessor behave differently than the magic methods? Should > > this just be documents or should this be fixed? > > sort() works just fine if you define __get to return by-ref. Returning by reference was not documented in the original RFC, would this syntax work for everyone? public $Hours { &get { return $this->a; } } > > -- > Stanislav Malyshev, Software Architect > SugarCRM: http://www.sugarcrm.com/ > (408)454-6900 ext. 227

« previous php.internals (#60256) next »