#41942 [Opn->Bgs]: array() does not implement Traversable

From: Date: Mon, 23 Jul 2007 23:14:48 +0000
Subject: #41942 [Opn->Bgs]: array() does not implement Traversable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115363@lists.php.net to get a copy of this message
ID: 41942 Updated by: helly@php.net Reported By: justin dot hendrickson+bugs dot php dot net at gmail dot co -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: Any PHP Version: 5.2.3 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Arrays are no objects thus they cannot implement an interface. Previous Comments: ------------------------------------------------------------------------ [2007-07-09 18:55:11] justin dot hendrickson+bugs dot php dot net at gmail dot co 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 this bug report at http://bugs.php.net/?id=41942&edit=1

« previous php.bugs (#115363) next »