Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19750 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15496 invoked by uid 1010); 26 Oct 2005 22:39:01 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15476 invoked from network); 26 Oct 2005 22:39:01 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Oct 2005 22:39:01 -0000 X-Host-Fingerprint: 194.109.193.120 unknown Linux 2.4/2.6 Received: from ([194.109.193.120:33701] helo=mx1.moulin.nl) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id 62/7F-22886-48500634 for ; Wed, 26 Oct 2005 18:39:01 -0400 Received: from localhost (localhost [127.0.0.1]) by mx1.moulin.nl (Postfix) with ESMTP id EC1D7175FF3; Thu, 27 Oct 2005 00:38:56 +0200 (CEST) Received: from mx1.moulin.nl ([127.0.0.1]) by localhost (moulin [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07758-03; Thu, 27 Oct 2005 00:38:55 +0200 (CEST) Received: from [10.0.13.92] (ip255-115-172-82.dyndsl.versatel.nl [82.172.115.255]) by mx1.moulin.nl (Postfix) with ESMTP id 8C3A9175FCD; Thu, 27 Oct 2005 00:38:55 +0200 (CEST) Message-ID: <4360057C.9010705@iamjochem.com> Date: Thu, 27 Oct 2005 00:38:52 +0200 User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ilia Alshanetsky Cc: Marcus Boerger , internals@lists.php.net References: <425333877.20051025002259@marcus-boerger.de> <435FF772.70206@prohost.org> In-Reply-To: <435FF772.70206@prohost.org> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at moulin.nl Subject: Re: [PHP-DEV] foreach with null From: jochem@iamjochem.com (Jochem Maas) Ilia Alshanetsky wrote: > IMHO this is a bad idea, if you really wanted to support NULL in a > particular case you, as a developer could do: > php -r '$n=NULL; foreach((array)$n as $v);' > > Making NULL usage transparent where array is expects will lead to > difficult to debug code. hi :-) the warning for foreach() in this case seems to be inconsistent with: php -r '$a = null; $b = array(); var_dump((empty($a) === empty($b)), (count($a) === count($b)));' which gives no warnings or otherwise, also as a lesser developer than you I don't buy the notion that dropping the warning makes debugging more difficult because advanced code should be checking vars properly before using them and, well, for any given foreach loop there is often enough an 'if (!count($array))'-like statement to take care of the 'empty' case. and in cases when speed is very important it saves an explicit cast (is that more expensive anyway?) and it means not requiring an '@' to suppress which I do know is more expensive than not having any E_* to suppress at all. on the face of it I understand begin against, feedback is good. but removing the warning would make the engine behaviour just a little more consistent - which is nice, no? did anyone remember that php5beta used to allow: function(MyCLass $x = null) {} which was nice from the start fom a user perspective, I was puzzled as to why it went, glad it came back and hope it says :-) thanks for php, and kind regards in general, jochem > > -1 for removing the warning. > > Ilia >