Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56487 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72466 invoked from network); 23 Nov 2011 09:24:39 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2011 09:24:39 -0000 Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.170 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 209.85.216.170 mail-qy0-f170.google.com Received: from [209.85.216.170] ([209.85.216.170:64282] helo=mail-qy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0A/14-45113-6DBBCCE4 for ; Wed, 23 Nov 2011 04:24:38 -0500 Received: by qyk33 with SMTP id 33so1006257qyk.29 for ; Wed, 23 Nov 2011 01:24:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8ztDdt/boZGE6sV+31mLHPto2tAcAizgYrMZT5/Ln6Y=; b=YLPUnJsYb0EWPhj6ctpPhscjiYdC0LXZROpU96SzXqpFc7AyOgMClcyDfYqhAYwXQ3 rrS2H0Jl0iokCAHEIT4tQnCwsDxdnZbP4cKO1zYlWEWvplSzg7zjpawTaoaH64AyrA9A yZ8PgmfAwXzOU6QmF6gFbSkuMezUU0eEp/8dk= MIME-Version: 1.0 Received: by 10.229.67.5 with SMTP id p5mr2599944qci.148.1322040275660; Wed, 23 Nov 2011 01:24:35 -0800 (PST) Received: by 10.229.38.134 with HTTP; Wed, 23 Nov 2011 01:24:35 -0800 (PST) In-Reply-To: <4ECCB549.904@lsces.co.uk> References: <20111123015008.GA12933@panix.com> <20111123023108.GA172@panix.com> <4ECCB549.904@lsces.co.uk> Date: Wed, 23 Nov 2011 10:24:35 +0100 Message-ID: To: Lester Caine Cc: PHP internals Content-Type: multipart/alternative; boundary=0016e64bff5a026ff804b2637d4b Subject: Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values From: tyra3l@gmail.com (Ferenc Kovacs) --0016e64bff5a026ff804b2637d4b Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, Nov 23, 2011 at 9:56 AM, Lester Caine wrote: > Etienne Kneuss wrote: > >> AFAIK this is one of the change that was explicitly put in to make it >>>> >> more consistent. >>>> >>> > >>> > But now it breaks code in the wild. I came across this due to an >>> > isset() in PEAR now passing when it didn't before. >>> >> PEAR is definitely doing some strange things:) Is it checking indices >> of a variables without checking first if it's an array? >> Sounds like the comeback of "Please don't break bad code!" seen with >> is_a:) >> >> IMO it still makes sense to make that change for 5_4, makes everything >> less magic and more consistent. >> > > I'm having a lot of trouble with working out WHAT is going on here at all= . > > https://bugs.php.net/bug.php?**id=3D60362as far as I can tell is using array and sub array elements? String= s don't > come into the equation? So I check if I've populated the sub-array be > seeing if a sub array element exists, such as would happen if I've > populated the array in a previous scan through, but now I'm getting sub > array elements caused by some conversion of the string making up the > element above? > > Now that this activity has been highlighted it may well explain why I'm > getting problems with a section of code that is building a complex tree > structure array from GEDCOM data strings ... since the code is not my own > working out where things were breaking down was a problem I simply do not > have time to investigate. It currently fails on PHP5.4 and it took some > time to tidy the code on 5.3 ... and that still only runs with warnings > switched off :( > > So what is the current preferred method of checking if sub array elements > have been created manually, rather than as 'less magic' string elements? > > some clarification: in the test script, Daniel declared $arr as: $arr =3D array('exists' =3D> 'foo'); so when he tests $arr['exists']['non_existent'] PHP will see that $arr['exists'] is a string, and it will convert the 'non_existent' index to int(0) and that will return the same as $arr['exists'][0]: 'f' If he would have defined $arr['exists'] as an array, then the code would work as he expected, empty would returned true for $arr['exists']['non_existent'] --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --0016e64bff5a026ff804b2637d4b--