File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / spl / tests / iterator_046.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:48:01 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
SPL: CachingIterator and __toString using bypassed string keys
--FILE--
<?php

class MyFoo
{
	function __toString()
	{
		return 'foo';
	}
}

class MyCachingIterator extends CachingIterator
{
	function __construct(Iterator $it, $flags = 0)
	{
		parent::__construct($it, $flags);
	}

	function fill()
	{
		echo __METHOD__ . "()\n";
		foreach($this as $v) ;
	}

	function show()
	{
		echo __METHOD__ . "()\n";
		foreach($this as $v)
		{
			var_dump((string)$this);
		}
	}
}

$it = new MyCachingIterator(new ArrayIterator(array(0, 'foo'=>1, 'bar'=>2)), CachingIterator::TOSTRING_USE_KEY);

$it->fill();
$it->show();

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
MyCachingIterator::fill()
MyCachingIterator::show()
string(1) "0"
string(3) "foo"
string(3) "bar"
===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>