#42795 [Opn->Bgs]: SPL Appendable interface

From: Date: Sat, 29 Sep 2007 18:37:32 +0000
Subject: #42795 [Opn->Bgs]: SPL Appendable interface
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117961@lists.php.net to get a copy of this message
ID: 42795 Updated by: cellog@php.net Reported By: david dot nqd at gmail dot com -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: N/A PHP Version: 5.2.4 New Comment: This is unnecessary. the offset is set to null when [] is requested <?php class test implements ArrayAccess { var $test = array(); function offsetGet($var) { return $this->test[$var]; } function offsetSet($var, $value) { if ($var === null) { $this->test[] = $value; } $this->test[$var] = $value; } function offsetExists($var) { return isset($this->test[$var]); } function offsetUnset($var) { unset($this->test[$var]); } } $a = new test; $a[] = 1; echo $a[0]; ?> Previous Comments: ------------------------------------------------------------------------ [2007-09-29 07:34:25] david dot nqd at gmail dot com Description: ------------ SPL interfaces provide useful interfaces to let objects behave like arrays; however, there is no way for objects to use the array append syntax method without having to extend either ArrayObject or ArrayIterator. I am suggesting that a new interface called Appendable be created to allow objects to have this functionality without having to be an extension of anything. Appendable would only contain a single method, but would almost always be used with ArrayAccess, Appendable differs from the feature request (#32347) I posted earlier since it is not an extension of ArrayAccess. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42795&edit=1

« previous php.bugs (#117961) next »