|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-19 17:08 UTC] requinix@php.net
-Summary: tested in https://3v4l.org/
+Summary: Iterating over an ArrayObject does not call offsetGet
-Status: Open
+Status: Not a bug
[2016-08-19 17:08 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 10:00:01 2025 UTC |
Description: ------------ offsetGet() don't called if ArrayObject uses in foreach(). It directly returns value from private storge of ArrayObject. Test script: --------------- class Some extends ArrayObject { function __construct(){ parent::__construct(array("key"=>"storged value"),ArrayObject::ARRAY_AS_PROPS); } function offsetGet($index){ return "offsetGet called"; } } $obj=new Some(); print $obj->key."<br>"; foreach($obj as $key=>$val){ print $val."<br>"; } Expected result: ---------------- offsetGet called storged value Actual result: -------------- offsetGet called offsetGet called