note 38120 deleted from ref.overload by sobak

From: Date: Tue, 22 Nov 2016 03:48:55 +0000
Subject: note 38120 deleted from ref.overload by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207444@lists.php.net to get a copy of this message
Note Submitter: John Martin ---- I've found a work around that allows overload to work with nested classes. I was trying to design a set of classes that I didn't need to define the setter/getter methods for each of the properties. I stayed away from the __get() and __set() function since this bypasses object encapsulation. Instead I use the __call() method to implement the accessor functions. The __call() function emulates the get{var name} and stores the variable into an internal array with in the class. The get{var name} checks the array for the var name and returns it if found. Using the Zend Dev Studio (Great Product!) I was able to debug the code and found that when overloaded objects are nested that the nested object somehow looses the array var. Just for giggles, I added a second variable and assigned the array var by reference. Some how this worked. class Base { var $_prop = array(); var $_fix; function Base() { // This somehow fixes the problem with nested overloading $this->_fix = & $this->_prop; } }

« previous php.notes (#207444) next »