ID: 48205
Updated by: [email protected]
Reported By: sean at practicalweb dot co dot uk
-Status: Open
+Status: Verified
Bug Type: SPL related
-Operating System: Linux
+Operating System: *
-PHP Version: 5.3CVS-2009-05-09 (snap)
+PHP Version: 5.*, 6CVS (2009-05-09)
New Comment:
Please, when you do testing, test with PHP_5_2 also and HEAD. And set
the version string like I did now in case the bug exists in all
branches..
Previous Comments:
------------------------------------------------------------------------
[2009-05-09 13:52:57] sean at practicalweb dot co dot uk
Description:
------------
If the current element of a RecursiveIteratorIterator has no children
then callGetChildren() causes an error message like
Fatal error: Uncaught exception 'InvalidArgumentException' with message
'Passed variable is not an array or object, using empty array instead'
This is confusing because the PHP code does not pass an argument here.
I think that either the method should return null when there are no
children - or at least the error message could be clearer.
This has been found as part of phptestfest 09 - an XFail test will be
commited from PHPLondon
My Apologies if this is expected behaviour, I realise the code is
undocumented, but I wanted to commit a test to cover this and filing a
bug seemed the best way to confirm one way or the other :-)
Reproduce code:
---------------
<?php
$array = array(array(7,8,9),1,2,3,array(4,5,6));
$recursiveArrayIterator = new RecursiveArrayIterator($array);
$test = new RecursiveIteratorIterator($recursiveArrayIterator);
var_dump($test->current());
$test->next();
var_dump($test->current());
try {
$output = $test->callGetChildren();
} catch (InvalidArgumentException $ilae){
$output = null;
print "invalid argument exception\n";
}
var_dump($output);
?>
Expected result:
----------------
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
int(7)
NULL
Actual result:
--------------
array(3) {
[0]=>
int(7)
[1]=>
int(8)
[2]=>
int(9)
}
int(7)
invalid argument exception
NULL
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48205&edit=1