ID: 49538
User updated by: kevinpeno at gmail dot com
Reported By: kevinpeno at gmail dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: ALL
PHP Version: 5.3.0
New Comment:
Dumbass moment on the offsetSet bug. Please ignore that part :P The
rest I still would like to see though :)
Previous Comments:
------------------------------------------------------------------------
[2009-09-12 22:16:28] kevinpeno at gmail dot com
Description:
------------
ArrayAccess should force the implementation of append to cover the case
of $array[] = somevalue so that one can properly handle values appended
in this manner. Additionally, most internal classes implementing
ArrayAccess add their own append method anyway and this would provide
some sort of naming standard.
Examples of conflicts in naming include ArrayObject::append() and
SplDoublyLinkedList::push()
Reproduce code:
---------------
<?php
class MyArrayObject extends ArrayObject
{
function append( $v )
{
//Should print the value if value appended
var_dump( 'Append:', $value );
}
function offsetSet( $k, $v )
{
//Will Print OffsetSet: \n NULL \n NULL - See
http://bugs.php.net/bug.php?id=49537
var_dump( 'offsetSet:', $k, $value );
}
}
$test = new MyArrayObject();
$test[] = 'test';
?>
Expected result:
----------------
MyArrayObject::append() called rather than MyArrayObject::offsetSet()
Actual result:
--------------
MyArrayObject::offsetSet() is called
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=49538&edit=1