Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87114 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7659 invoked from network); 12 Jul 2015 00:20:59 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Jul 2015 00:20:59 -0000 Authentication-Results: pb1.pair.com smtp.mail=tjerk.meesters@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tjerk.meesters@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.195 as permitted sender) X-PHP-List-Original-Sender: tjerk.meesters@gmail.com X-Host-Fingerprint: 209.85.213.195 mail-ig0-f195.google.com Received: from [209.85.213.195] ([209.85.213.195:34593] helo=mail-ig0-f195.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/63-32599-6E2B1A55 for ; Sat, 11 Jul 2015 20:20:55 -0400 Received: by igczg2 with SMTP id zg2so4055941igc.1 for ; Sat, 11 Jul 2015 17:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=BowADvUNO51oyr6jZvSe005gOY9Mje9jIiBUU1OcOu4=; b=czO2JC3iinGrIJMUvaUKhCvJhMjb2lkgqCEsEzqQfVXLafKnR9Wf4K6r1NxqRhqEOL ibK7UBckooID03nzSI1G9+O7sPGpgwVWjbQyftyxLd1Q4E/n1jNT9C/w9/R3P6DvBtwq qAxd13aar8C7vxbI7mPiKzXvuvyiEu2mXOI216hclVSI/f+2w7S/kcl5Z+gTfcnPOZRj i+5BmWWoypdE8efS5KLluNBjWpKJmO1cLfkDn6Ok3UoizzXt5MBVMa0OfOxSXjZE422P /WVPIr4KZnU+qwVPtEOBpx63UHnvKe6weUUNVDQDeebnI4WBAJ99Zfm8tb1Haw/iIsx8 0HUQ== X-Received: by 10.107.153.5 with SMTP id b5mr9860478ioe.143.1436660066537; Sat, 11 Jul 2015 17:14:26 -0700 (PDT) MIME-Version: 1.0 References: <55A16593.7030608@ralphschindler.com> In-Reply-To: <55A16593.7030608@ralphschindler.com> Date: Sun, 12 Jul 2015 00:14:17 +0000 Message-ID: To: Ralph Schindler , PHP Internals List Content-Type: multipart/alternative; boundary=001a1140eaaaedd906051aa27c16 Subject: Re: [PHP-DEV] Possible Bug or Bad Expectations? From: tjerk.meesters@gmail.com (Tjerk Meesters) --001a1140eaaaedd906051aa27c16 Content-Type: text/plain; charset=UTF-8 On Sun, Jul 12, 2015 at 2:52 AM Ralph Schindler wrote: > Hi all, > > I am conflicted as per if what I experience in this code should be > throwing a notice in E_STRICT: > > http://3v4l.org/srm5f > > error_reporting(E_ALL); > $foo = ['bar' => ['baz' => 5]]; > $bar = ['box' => 'baz']; > > // this will Notice: Undefined index: boom > var_dump(isset($foo['bar'][$bar['boom']])); > > > Essentially, my expectation is that anything inside an isset() would be > immune from notices of undefined indexes, but that is not the case with > nested array key lookups. > You're not getting a notice for the undefined index `$foo['bar'][null]`, that's basically what isset() is made to do. If you want to guard against undefined indices in an array that you're using to dereference `$foo` you need this: var_dump(isset($bar['boom'], $foo['bar'][$bar['boom']])); > > Is this a bad expectation to have? Or should isset() silence the nested > undefined index as well? I also realized this has always been the > behavior leading me to believe I might have a bad expectation here. In > any case wanted to check. > > Thanks, > -ralph > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a1140eaaaedd906051aa27c16--