Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19730 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93926 invoked by uid 1010); 26 Oct 2005 17:50:26 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 93911 invoked from network); 26 Oct 2005 17:50:26 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Oct 2005 17:50:26 -0000 X-Host-Fingerprint: 213.46.255.27 viefep11-int.chello.at Solaris 8 (1) Received: from ([213.46.255.27:10667] helo=viefep19-int.chello.at) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id A5/10-22886-0E1CF534 for ; Wed, 26 Oct 2005 13:50:25 -0400 Received: from genuine ([80.108.128.16]) by viefep19-int.chello.at (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20051026175021.UPGR22340.viefep19-int.chello.at@genuine>; Wed, 26 Oct 2005 19:50:21 +0200 Received: from laptop.home ([192.168.1.50]) by genuine with esmtpa (Exim 4.50) id 1EUpNO-0003iE-FU; Wed, 26 Oct 2005 19:47:50 +0200 Message-ID: <435FC1F0.9090303@fischer.name> Date: Wed, 26 Oct 2005 19:50:40 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.6) Gecko/20050317 Thunderbird/1.0.2 Mnenhy/0.7.2.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Sebastian CC: internals@lists.php.net References: <4e36d31d0510261018t639c472x9efaaf7af61a9ddb@mail.gmail.com> In-Reply-To: <4e36d31d0510261018t639c472x9efaaf7af61a9ddb@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -27 X-Spam-Level: -- X-Spam-Report: Spam detection software, running on the system "genuine", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Sebastian wrote: > Good code is code that's easy to debug (among other things). By > removing the "Invalid argument supplied for foreach()" warning without > providing mechanisms to turn it on, debugging code will be more > difficult. Logically speaking, when does it make sense to iterate over > something that isn't an array? > > If I were writing one-time use scripts that I will never use again > (not likely) this might be desired behavior. If I were writing code > that is used by other programmers, paying users, and under conditions > likely to change (implying changing code, and often debugging and > testing), the ability to detect errors as early as possible is vital > (The Pragmatic Programmer is a good reference for this). Most people > don't want to spend more time than is necessary to troubleshoot code. > Probably more importantly, managers and customers don't want to wait > longer for a product they're paying for. [...] Content analysis details: (-2.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -2.8 ALL_TRUSTED Did not pass through any untrusted hosts Subject: Re: [PHP-DEV] Re: foreach with null From: markus@fischer.name (Markus Fischer) Sebastian wrote: > Good code is code that's easy to debug (among other things). By > removing the "Invalid argument supplied for foreach()" warning without > providing mechanisms to turn it on, debugging code will be more > difficult. Logically speaking, when does it make sense to iterate over > something that isn't an array? > > If I were writing one-time use scripts that I will never use again > (not likely) this might be desired behavior. If I were writing code > that is used by other programmers, paying users, and under conditions > likely to change (implying changing code, and often debugging and > testing), the ability to detect errors as early as possible is vital > (The Pragmatic Programmer is a good reference for this). Most people > don't want to spend more time than is necessary to troubleshoot code. > Probably more importantly, managers and customers don't want to wait > longer for a product they're paying for. I also don't feel very comfortable with silencing the warning for NULL. If the variable is not an array and not traversable there's nothing to iterate over and it should tell the user. If we intentionally want to not know about this error, an alternate syntax with the '@' operator should be considered as it was requested in the past, e.g. '@foreach' or 'foreach(@$notarrayOrIterable ...'. - Markus