|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-07-23 23:14 UTC] helly@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 20:00:01 2025 UTC |
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