Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61182 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30487 invoked from network); 12 Jul 2012 17:40:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2012 17:40:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.21 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.21 smtp1.ist.utl.pt Linux 2.6 Received: from [193.136.128.21] ([193.136.128.21:39585] helo=smtp1.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 91/04-11045-81C0FFF4 for ; Thu, 12 Jul 2012 13:40:41 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp1.ist.utl.pt (Postfix) with ESMTP id AEAF2700044A for ; Thu, 12 Jul 2012 18:40:36 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp1.ist.utl.pt ([127.0.0.1]) by localhost (smtp1.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id BfX0Uhxyy8-k for ; Thu, 12 Jul 2012 18:40:36 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp1.ist.utl.pt (Postfix) with ESMTP id 6845970004E8 for ; Thu, 12 Jul 2012 18:40:36 +0100 (WEST) Received: from damnation (unknown [IPv6:2001:470:94a2:4:bd8e:7516:c06:6a6d]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id C378F200D070 for ; Thu, 12 Jul 2012 18:40:35 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <4FFEFBB3.7090507@sugarcrm.com> Date: Thu, 12 Jul 2012 19:40:31 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: <4FFEFBB3.7090507@sugarcrm.com> User-Agent: Opera Mail/12.50 (Linux) Subject: Re: [PHP-DEV] Iterable Type Hint From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") Em Thu, 12 Jul 2012 18:30:43 +0200, Stas Malyshev escreveu: >> Would it be worth while adding a new type hint that checks for this >> condition? I'd propose Iterable: > > I see more and more multiplication of weird ad-hoc type checks. First we > had "callable", now "traversable", then we invent more and more weird > functional types with complex logic. I don't like this development at > all. It's ad-hoc introducing of half-baked, unstandartized, undesigned > strict typing. Strict typing is not a good idea for PHP, and weird > strict typing based on complex conditions hidden from the user is even > worse IMO. I agree with everything Stas said. Additionally, while "callable" has a problem that "iterable" wouldn't have -- namely, whether something is callable is context sensitive* -- its implementation was accompanied by a homogenization of callable types (e.g., you can now do $a = $func = ['A', 'foo']; $a()). Traversable types are by no means interchangeable. In fact the only thing they have in common is that can be passed to foreach. On everything else, they're different. It makes to sense to a pseudo-type for two entities that all they have in common is that one property. * Example: class A { public static function foo(callable $r) { B::foo($r); } private static function test() {} } class B { public static function foo(callable $r) {} } A::foo(['A', 'test']); -- Gustavo Lopes