ID: 42795
Updated by: [EMAIL PROTECTED]
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