note 115110 added to class.filteriterator
| From: | Anonymous | Date: | Tue, 27 May 2014 08:02:01 +0000 |
| Subject: | note 115110 added to class.filteriterator | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-199631@lists.php.net to get a copy of this message | ||
A little test about the function call order:
<?php
class TestIterator extends IteratorIterator
{
public function key()
{
echo __FUNCTION__, PHP_EOL;
return parent::key();
}
public function next()
{
echo __FUNCTION__, PHP_EOL;
return parent::next();
}
public function rewind()
{
echo __FUNCTION__, PHP_EOL;
return parent::rewind();
}
public function valid()
{
echo __FUNCTION__, PHP_EOL;
return parent::valid();
}
}
class TestFilterIterator extends FilterIterator
{
public function accept()
{
echo __FUNCTION__, PHP_EOL;
return true;
}
}
$iterator = new ArrayIterator(array('a', 'b', 'c'));
foreach (new TestFilterIterator(new TestIterator($iterator)) as $k => $v) {
echo PHP_EOL;
}
?>
This will output the following:
rewind
valid
key
accept
next
valid
key
accept
next
valid
key
accept
next
valid
----
Server IP: 72.52.91.14
Probable Submitter: 90.42.109.23
----
Manual Page -- http://php.net/manual/en/class.filteriterator.php
Edit -- https://master.php.net/note/edit/115110
Del: integrated -- https://master.php.net/note/delete/115110/integrated
Del: useless -- https://master.php.net/note/delete/115110/useless
Del: bad code -- https://master.php.net/note/delete/115110/bad+code
Del: spam -- https://master.php.net/note/delete/115110/spam
Del: non-english -- https://master.php.net/note/delete/115110/non-english
Del: in docs -- https://master.php.net/note/delete/115110/in+docs
Del: other reasons-- https://master.php.net/note/delete/115110
Reject -- https://master.php.net/note/reject/115110
Search -- https://master.php.net/manage/user-notes.php