On 2 December 2010 13:51, <presid...@basnetworks.net> wrote: >> 2010/12/1 Richard Quadling <rquadl...@gmail.com> >> >>> On 1 December 2010 09:22, Stas Malyshev <smalys...@sugarcrm.com> wrote: > ... > >> Why change the expected behavior of isset? If a property has not been set >> then isset must return false, and that includes $foo->name = NULL. > > > Thats simple then, when isset is invoked, call the get method, and if it > returns null then isset() returns false, but otherwise returns true. That > was likely just a small oversight on Richard's part.
No, it was not an oversight. Calling the getter() in response to isset() will probably result in a change to the value of the property. For a property, isset() can and only be interested in the last value of the property, not the next value. As I understand things, isset() performs 2 tests. First a check to see if the variable exists and then to see if it has a value assigned. For a property, the first part of that equation is fairly simple - the property has to exist or not. The second part though is not easy. A variable will not change value in response to isset(), but, if isset() calls the getter(), then it could and probably would. Calling isset() shouldn't alter anything. Having isset() call the getter() and unset() call the setter() is fine as long as the getter() and setter() know why they are being called. If the developer needs to supply the last value - their choice - then this could be implemented by caching the last value in a local scope static. Completely encapsulated. get($isset = false){ static $lastValue; if (!$isset) { // Generate the new value and assign it to $lastValue } return $lastValue; } Richard. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php