Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56517 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 59819 invoked from network); 23 Nov 2011 17:59:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Nov 2011 17:59:07 -0000 Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.49 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.216.49 mail-qw0-f49.google.com Received: from [209.85.216.49] ([209.85.216.49:60765] helo=mail-qw0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BB/A1-47904-A643DCE4 for ; Wed, 23 Nov 2011 12:59:07 -0500 Received: by qadc16 with SMTP id c16so1823971qad.8 for ; Wed, 23 Nov 2011 09:59:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=MPpWXW5bgDy8HMvRy3LggWo6k/gSOmrnCbuuA6F93u0=; b=M4dMotx483Z+WAo9iJlh+0IwoHMYR1i46S7HjwakmMvKL6T/cfHIe7k3ztYy1nNxMH Yn/8Rka/GCwQpZFeXsBg9LxrH4rqccvokGcXEr92TxaW+H194ZnMgqBjfH4V14/SmRmG Nz85VeyyAekNLI75AvCUgB3iU5b/GhL5zGVIs= Received: by 10.182.222.106 with SMTP id ql10mr6973513obc.53.1322071143159; Wed, 23 Nov 2011 09:59:03 -0800 (PST) MIME-Version: 1.0 Received: by 10.182.42.226 with HTTP; Wed, 23 Nov 2011 09:58:42 -0800 (PST) Reply-To: RQuadling@GMail.com In-Reply-To: <20111123153100.GB13420@panix.com> References: <20111123015008.GA12933@panix.com> <20111123023108.GA172@panix.com> <4ECCB549.904@lsces.co.uk> <4ECCBC56.3050602@sugarcrm.com> <20111123141408.GA11940@panix.com> <20111123153100.GB13420@panix.com> Date: Wed, 23 Nov 2011 17:58:42 +0000 Message-ID: To: Daniel Convissor Cc: Stas Malyshev , PHP internals Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.4 regression: non-existent sub-sub keys now have values From: rquadling@gmail.com (Richard Quadling) On 23 November 2011 15:31, Daniel Convissor wrote: > Hi Again Folks: > > On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote: >> $a =3D 'foo'; >> echo $a['blah'] . "\n"; >> >> But that second one echos out "f". =C2=A0This is a huge WTF. > > Two things for the record on this front. =C2=A0First, i've been actively > using PHP for, what, ten years or so, and have never run into this > behavior before. =C2=A0Second, this behavior turns the following one line= r: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (isset($arr['package']['attribs']['version'= ])) { > > Into this: > > =C2=A0 =C2=A0 =C2=A0 =C2=A0if (is_array($arr) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& array_key_exist= s('package', $arr) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& is_array($arr['= package']) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& array_key_exist= s('attribs', $arr['package']) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& is_array($arr['= package']['attribs']) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& array_key_exist= s('version', $arr['package']['attribs']) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&& !empty($arr['pa= ckage']['attribs']['version'])) > =C2=A0 =C2=A0 =C2=A0 =C2=A0{ I agree with Daniel on this. Just looking for any test relating to isset() to see what tests will now fa= il. Neither of the isset() tests ext/standard/tests/general_functions look at arrays with associative indices. The behaviour with regard to unavailable associative indices has no tests. But using loose typing as a fallback for non existent keys seems really really wrong. Especially if the key is a constant. On what planet should ... isset($arr['exists']['test_existance']) should become isset($arr['exists'][= 0]) That just seems really wrong and the work around is awful. --=20 Richard Quadling Twitter : EE : Zend : PHPDoc : Fantasy Shopper @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea=C2=A0: fan.sh/6/370