#41942 [NEW]: array() does not implement Traversable

From: Date: Mon, 09 Jul 2007 18:55:11 +0000
Subject: #41942 [NEW]: array() does not implement Traversable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-114814@lists.php.net to get a copy of this message
From: justin dot hendrickson+bugs dot php dot net at gmail dot com Operating system: Any PHP version: 5.2.3 PHP Bug Type: Feature/Change Request Bug description: array() does not implement Traversable Description: ------------ Passing an array as a parameter with a type hint of Traversable causes a fatal error. I'd be nice if the basic array type could implement this interface so it can be used like this. It appears this request is a duplicate of 33891, however it doesn't not appear to have any activity for almost 1 year. Reproduce code: --------------- function traversableTest(Traversable $items) { foreach($items as $item) { echo $item; } } traversableTest(array('one', 'two', 'three')); Expected result: ---------------- onetwothree Actual result: -------------- Catchable fatal error: Argument 1 passed to traversableTest() must implement interface Traversable, array given, called in /home/jhendric/public_html/test.php on line 8 and defined in /home/jhendric/public_html/test.php on line 2 -- Edit bug report at http://bugs.php.net/?id=41942&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41942&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41942&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41942&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41942&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41942&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41942&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41942&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41942&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41942&r=support Expected behavior: http://bugs.php.net/fix.php?id=41942&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41942&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41942&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41942&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41942&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41942&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41942&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41942&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41942&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41942&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41942&r=mysqlcfg

« previous php.bugs (#114814) next »