ID: 45820 Updated by: col...@php.net Reported By: t...@php.net -Status: Assigned +Status: Closed Bug Type: SPL related Operating System: Gentoo PHP Version: 5.2.6 Assigned To: colder New Comment:
This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2008-08-14 12:45:46] lstro...@php.net In 5.3 it behaves differently: $ php -r '$a = new ArrayObject(); $a[''] = "foo"; var_dump($a);' object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(1) { [0]=> string(3) "foo" } } ------------------------------------------------------------------------ [2008-08-14 12:13:57] t...@php.net Description: ------------ While '' works as an array key, it does not work with ArrayObject. It should either work both or none (first one preferred). Reproduce code: --------------- php > $foo = new ArrayObject(); php > $foo[''] = 'lala'; PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An offset must not begin with \0 or be empty' in php shell code:1 Stack trace: #0 php shell code(1): unknown() #1 {main} thrown in php shell code on line 1 InvalidArgumentException: An offset must not begin with \0 or be empty in php shell code on line 1 Call Stack: 16.7554 63916 1. {main}() php shell code:0 Expected result: ---------------- Same as for arrays. php > $foo = array(); php > $foo[''] = 'lala'; php > var_dump($foo); array(1) { [""]=> string(4) "lala" } Actual result: -------------- PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An offset must not begin with \0 or be empty' in php shell code:1 Stack trace: #0 php shell code(1): unknown() #1 {main} thrown in php shell code on line 1 InvalidArgumentException: An offset must not begin with \0 or be empty in php shell code on line 1 Call Stack: 16.7554 63916 1. {main}() php shell code:0 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45820&edit=1