Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61166 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98379 invoked from network); 12 Jul 2012 14:10:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 14:10:25 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.216.42 mail-qa0-f42.google.com Received: from [209.85.216.42] ([209.85.216.42:60428] helo=mail-qa0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/A9-46517-1DADEFF4 for ; Thu, 12 Jul 2012 10:10:25 -0400 Received: by qafi31 with SMTP id i31so4215275qaf.8 for ; Thu, 12 Jul 2012 07:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=kIrfflF6sZISXInFD/J3so4nG9zrVhMTVH1ndrgpVdQ=; b=TEDkt7FbRay4JRYkPL32r245H8W4Td1hM7aPb+KdL+j2YftIkzOYMRJe+ettciA6GD TybH70hLFVQGglirzrqZm5pXuK3oPZA98cFVbUl1wDYhoRxQ2JFYr+IPkEs5XZ6E7WT4 8urJlHsa6x+51PpcxQatNa05UOev04V3Qo9VoVDKRqiH1jxwzw/zwrMGrNFYcT3gIMWr tKahV332C1R89qcfZP5GcWQ8juhNpWDP81X4edxNcfarkdSi0qtAGhICSPLBdFRTo6r7 pBJmMh9czL8mIEr2vQVp6+B09//lA8446E/xre/uACmfkIFHm6XuJ5/72BqfJfWcHe74 oAag== MIME-Version: 1.0 Received: by 10.229.137.147 with SMTP id w19mr23946428qct.44.1342102222480; Thu, 12 Jul 2012 07:10:22 -0700 (PDT) Received: by 10.229.232.11 with HTTP; Thu, 12 Jul 2012 07:10:22 -0700 (PDT) Date: Thu, 12 Jul 2012 10:10:22 -0400 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=00235452f64c3925b604c4a2862f Subject: Iterable Type Hint From: ircmaxell@gmail.com (Anthony Ferrara) --00235452f64c3925b604c4a2862f Content-Type: text/plain; charset=ISO-8859-1 Hello all, At present, there's now way to type hint over a generic structure that it iteratable using foreach(). You can accept arrays using the array hint, and objects using traversable, but you cannot hint both. This yields code that wants to accept that to look like this: function foo($a) { if (!is_array($a) && !$a instanceof Traversable) { raise error; } } Would it be worth while adding a new type hint that checks for this condition? I'd propose Iterable: function foo(Iterable $a) { foreach ($a as ...) {} } It's just a quick thought and wanted some feedback on it. Thanks Anthony --00235452f64c3925b604c4a2862f--