note 83213 deleted from language.oop5.overloading by danielc

From: Date: Sat, 19 Jul 2008 23:08:59 +0000
Subject: note 83213 deleted from language.oop5.overloading by danielc
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-141782@lists.php.net to get a copy of this message
Note Submitter: durist at frii dot com Reason: 1 ---- get_object_vars() cannot see members managed by __get() and __set(). Seems to me this is a bug... <?php class MemberTest { /** Location for overloaded data. */ private $data = array(); public function __set($name, $value) { echo "Setting '$name' to '$value'\n"; $this->data[$name] = $value; } public function __get($name) { echo "Getting '$name'\n"; if (array_key_exists($name, $this->data)) { return $this->data[$name]; } $trace = debug_backtrace(); trigger_error( 'Undefined property: ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE); return null; } } $obj = new MemberTest; $obj->a = 1; echo $obj->a . "\n"; var_dump( get_object_vars($obj) ); ?> .................................. Setting 'a' to '1' Getting 'a' 1 durist@yorga:~$ php /tmp/t.php Setting 'a' to '1' Getting 'a' 1 array(0) { }

« previous php.notes (#141782) next »