|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-07 11:21 UTC] colder@php.net
[2009-06-07 11:46 UTC] angafenion at yahoo dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 09:00:01 2025 UTC |
Description: ------------ I overrode the methods of ArrayObject to normalize the keys before setting and getting members. It appears that the overridden methods are skipped when modifying an array member. Reproduce code: --------------- <?php class foo extends ArrayObject { public function __construct($data = array(), $flags = self::ARRAY_AS_PROPS, $iterator = "ArrayIterator") { parent::__construct($data, $flags, $iterator); } public function offsetSet($key, $val) { echo "offsetSet invoked\n"; parent::offsetSet($key, $val); } public function offsetGet($key) { echo "offsetGet invoked\n"; return parent::offsetGet($key); } } $foo = new foo(); $foo->baz = array(); echo count($foo->baz) . "\n"; echo "---\n"; $foo->baz['bar'] = 'foo'; echo count($foo->baz) . "\n"; Expected result: ---------------- offsetSet invoked offsetGet invoked 0 --- offsetGet invoked --[*] offsetSet invoked _/ offsetGet invoked 1 [*] actually, I'm not sure exactly what output to expect here, but at least one of these I think should appear Actual result: -------------- offsetSet invoked offsetGet invoked 0 --- offsetGet invoked 1