From: sean at practicalweb dot co dot uk
Operating system: Linux
PHP version: 5.3CVS-2009-05-09 (snap)
PHP Bug Type: SPL related
Bug description: RecursiveIteratorIterator->callGetChildren() raises
InvalidArgumentException
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 bug report at http://bugs.php.net/?id=48205&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=48205&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=48205&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=48205&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=48205&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=48205&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=48205&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=48205&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=48205&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=48205&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=48205&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=48205&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=48205&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=48205&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=48205&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48205&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48205&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=48205&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=48205&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=48205&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=48205&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=48205&r=mysqlcfg