Doc #64528 [Opn->Nab]: ParentIterator doc refers to RecursiveIteratorIterator (wrong)
| From: | salathe@php.net | Date: | Tue, 26 Mar 2013 23:17:25 +0000 |
| Subject: | Doc #64528 [Opn->Nab]: ParentIterator doc refers to RecursiveIteratorIterator (wrong) | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-9698@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64528&edit=1
ID: 64528
Updated by: salathe@php.net
Reported by: jon at langevin dot me
Summary: ParentIterator doc refers to
RecursiveIteratorIterator (wrong)
-Status: Open
+Status: Not a bug
Type: Documentation Problem
Package: Documentation problem
PHP Version: 5.3.23
-Assigned To:
+Assigned To: salathe
Block user comment: N
Private report: N
New Comment:
The description could be worded better, but your interpretation is not what is being said. The
page does not say that the ParentIterator can be used to iterate a RecursiveIteratorIterator,
rather (in a slightly unclear, more concise way) that the effect of using ParentIterator when
provided to a RecursiveIteratorIterator is such that only elements with children are accepted.
Some background knowledge is required to easily make sense of the description, so I can see where
you stumbled.
The user contributed code to which you refer is also incorrect. RecursiveIteratorIterator does
not implement the RecursiveIterator interface, so a (catchable) fatal error is raised. The code
should instead wrap the RecursiveDirectoryIterator inside a ParentIterator and then provide that
to the RecursiveIteratorIterator.
Marking this as "not a bug" since the existing text is correct. However, I will look at
editing
both the description and the user contributed code.
Previous Comments:
------------------------------------------------------------------------
[2013-03-26 21:38:34] jon at langevin dot me
Description:
------------
ParentIterator docs say that it can be used to iterate a
RecursiveIteratorIterator, but that is incorrect, as ParentIterator is expecting
RecursiveIterator or a child class.
While it would make sense for ParentIterator to accept RecursiveIteratorIterator,
that's not the case currently, so anyone trying to follow the documentation will
get an error.
The class signature for ParentIterator correctly shows that it accepts
RecursiveIterator, but the doc does not support that.
There is a comment on the doc page from a user showing code, using
RecursiveIteratorIterator as an argument to ParentIterator (apparently it was
successful for him?), which suggests this may actually work in a different
version of PHP.
Documentation error can be seen here:
http://www.php.net/manual/en/class.parentiterator.php
Test script:
---------------
new \ParentIterator(new \RecursiveIteratorIterator(new \RecursiveIterator,
\RecursiveIteratorIterator::CHILD_FIRST));
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64528&edit=1