note 99105 deleted from class.arrayaccess by danbrown

From: Date: Fri, 30 Jul 2010 16:39:24 +0000
Subject: note 99105 deleted from class.arrayaccess by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171258@lists.php.net to get a copy of this message
Note Submitter: uramihsayibok, gmail, com ---- Actually, max at flashdroid, that code doesn't demonstrate returning references. While get() may return by-ref, offsetGet() does not so you don't get a reference. If you wanted a reference you'd have to use <?php public function &offsetGet($offset) { return $this->get($offset); } ?> but that raises the "declaration of X must be compatible with Y" fatal error. So no, you still cannot return references via ArrayAccess. (The code "works" because <?php $obj['name'] = "boo"; ?> triggers offsetSet, not offsetGet.)

« previous php.notes (#171258) next »