Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:19765 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55276 invoked by uid 1010); 27 Oct 2005 18:20:41 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 55261 invoked from network); 27 Oct 2005 18:20:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Oct 2005 18:20:41 -0000 X-Host-Fingerprint: 81.169.182.136 ajaxatwork.net Linux 2.4/2.6 Received: from ([81.169.182.136:57483] helo=strato.aixcept.de) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id ED/90-22886-87A11634 for ; Thu, 27 Oct 2005 14:20:41 -0400 Received: from [192.168.1.3] (dslb-084-063-008-173.pools.arcor-ip.net [84.63.8.173]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by strato.aixcept.de (Postfix) with ESMTP id BABE635C393; Thu, 27 Oct 2005 20:23:51 +0200 (CEST) Date: Thu, 27 Oct 2005 20:20:48 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <3410416193.20051027202048@marcus-boerger.de> To: Jochem Maas Cc: Jani Taskinen , Ilia Alshanetsky , In-Reply-To: <4360B0D5.5080202@iamjochem.com> References: <425333877.20051025002259@marcus-boerger.de> <435FF772.70206@prohost.org> <4360057C.9010705@iamjochem.com> <4360B0D5.5080202@iamjochem.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] foreach with null From: helly@php.net (Marcus Boerger) Hello Jochem, Thursday, October 27, 2005, 12:49:57 PM, you wrote: > Jani Taskinen wrote: >> On Thu, 27 Oct 2005, Jochem Maas wrote: >> >>> 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 >> >> >> ..and where count() magically returns 1 f.e. for FALSE. :) >> So really you can't rely on that. :) > true - although personally I always do if(is_array($r) && count($r)) in such cases. > so it seems that there is inconsistency regardless of > whether the warning is removed or not. > out of interest what are the ramifications for SPL and simpleXML > if the warning is not dropped? Right now ther is no place in SPL that would benefit. But both SXE and PDO have to create empty instances to allow code that does not need further cehecks before sending to foreach(). So the idea is actually some speed improvement and in case of SimpleXML i'd like to be able to check existance of a sub element by the following: !is_null($sxe->element) Best regards, Marcus