php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35734 RecursiveIteratorIterator constructor fails to recognize mode constants
Submitted: 2005-12-19 16:27 UTC Modified: 2005-12-19 19:31 UTC
From: dpantel at gmail dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.1.1 OS: RHES (linux 2.4.21-37)
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dpantel at gmail dot com
New email:
PHP Version: OS:

 

 [2005-12-19 16:27 UTC] dpantel at gmail dot com
Description:
------------
RecursiveIteratorIterator constructor fails to recognize mode constants.

The constructor works fine when passed only a RecursiveIterator object.  It also functions correctly if passed a RecursiveIterator object and an integer (0,1,2, etc) as the second (mode) argument.  However, if one attempts to pass a documented constant keyword (RIT_SELF_FIRST or SELF_FIRST), the constructor fails.

Note: different documentations show different constant definitions (RIT_SELF_FIRST vs SELF_FIRST). I have tried both, and neither one works.

Reproduce code:
---------------
class Rit implements RecursiveIterator {...}

$test = new Rit();

//work fine
$rii = new RecursiveIteratorIterator($test);
$rii = new RecursiveIteratorIterator($test, 1);

//do not work
$rii = new RecursiveIteratorIterator($test, RIT_SELF_FIRST);
$rii = new RecursiveIteratorIterator($test, SELF_FIRST);

//even tried this, with no avail
$rii = new RecursiveIteratorIterator($test, RecursiveIteratorIterator::RIT_SELF_FIRST);
$rii = new RecursiveIteratorIterator($test, RecursiveIteratorIterator::SELF_FIRST);


Expected result:
----------------
A RecursiveIteratorIterator object

Actual result:
--------------
Notice: Use of undefined constant RIT_SELF_FIRST - assumed 'RIT_SELF_FIRST' in /www/rit.class.php on line 276

(or Notice: Use of undefined constant SELF_FIRST - assumed 'SELF_FIRST' in /www/rit.class.php on line 276)


Fatal error: Uncaught exception 'InvalidArgumentException' with message 'An instance of RecursiveIterator or IteratorAggregate creating it is required' in /www/rit.class.php:276 Stack trace: #0 /www/rit.class.php(276): RecursiveIteratorIterator->__construct(Object(treeIterator), 'RIT_SELF_FIRST') ...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-19 16:31 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

Those are class constants now:

RecursiveIteratorIterator::SELF_FIRST

 [2005-12-19 16:38 UTC] dpantel at gmail dot com
If you take the time to read the bug report, you will notice that I have tried using `RecursiveIteratorIterator::SELF_FIRST` without success.
 [2005-12-19 19:29 UTC] dpantel at gmail dot com
My appologies.  I have recompiled PHP 5.1.1 and `RecursiveIteratorIterator::SELF_FIRST` now works.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC