From: quick_defect at yahoo dot com
Operating system: redhat
PHP version: 5.1.2
PHP Bug Type: SPL related
Bug description: CachingIterator::__tostring do not work
Description:
------------
First,I want to know how to use __tostring.But there is not doc. So I
tried with -3:
and what I get:
Fatal error: Uncaught exception 'InvalidArgumentException' with message
'Flags must contain only one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY,
CIT_TOSTRING_USE_CURRENT' in CachingIterator::__tostring.php:12
Stack trace:
#0 CachingIterator::__tostring.php(12):
CachingIterator->__construct(Object(ArrayIterator), -3)
#1 {main}
thrown in CachingIterator::__tostring.php on line 12
So I know I should use CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY or
CIT_TOSTRING_USE_CURRENT.
then I tried:
$ak=(new CachingIterator($asx,CIT_TOSTRING_USE_KEY ));
But I again got an exception which prompted that the argument was still
invalid.
Reproduce code:
---------------
<?php
error_reporting(E_ALL);
$asp=array("one"=>1,"two"=>2,"three"=>3,"four"=>4,"five"=>5,"six"=>6);
$kfc=array("trap");
$jsp=(new ArrayObject($asp));
$mcd=(new ArrayObject($kfc));
$asx=$jsp->getIterator();
$coca=$mcd->getIterator();
$ak=(new CachingIterator($asx,CIT_TOSTRING_USE_KEY ));
?>
Expected result:
----------------
no exception throwed out
Actual result:
--------------
Fatal error: Uncaught exception 'InvalidArgumentException' with message
'CachingIterator::__construct() expects parameter 2 to be long, string
given' in CachingIterator::__tostring.php:12
Stack trace:
#0 CachingIterator::__tostring.php(12):
CachingIterator->__construct(Object(ArrayIterator), 'CIT_TOSTRING_US...')
#1 {main}
thrown in CachingIterator::__tostring.php on line 12
--
Edit bug report at http://bugs.php.net/?id=36098&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36098&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36098&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36098&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36098&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36098&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36098&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36098&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36098&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36098&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36098&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36098&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36098&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36098&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36098&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36098&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36098&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36098&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36098&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36098&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36098&r=mysqlcfg