1--TEST-- 2SPL: CachingIterator and __toString using bypassed string keys 3--FILE-- 4<?php 5 6class MyFoo 7{ 8 function __toString() 9 { 10 return 'foo'; 11 } 12} 13 14class MyCachingIterator extends CachingIterator 15{ 16 function __construct(Iterator $it, $flags = 0) 17 { 18 parent::__construct($it, $flags); 19 } 20 21 function fill() 22 { 23 echo __METHOD__ . "()\n"; 24 foreach($this as $v) ; 25 } 26 27 function show() 28 { 29 echo __METHOD__ . "()\n"; 30 foreach($this as $v) 31 { 32 var_dump((string)$this); 33 } 34 } 35} 36 37$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 'bar'=>2)), CachingIterator::TOSTRING_USE_KEY); 38 39$it->fill(); 40$it->show(); 41 42?> 43===DONE=== 44<?php exit(0); ?> 45--EXPECTF-- 46MyCachingIterator::fill() 47MyCachingIterator::show() 48string(1) "0" 49string(3) "foo" 50string(3) "bar" 51===DONE=== 52