Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:87913 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61130 invoked from network); 25 Aug 2015 15:09:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Aug 2015 15:09:14 -0000 Authentication-Results: pb1.pair.com header.from=cmbecker69@gmx.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cmbecker69@gmx.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmx.de designates 212.227.17.21 as permitted sender) X-PHP-List-Original-Sender: cmbecker69@gmx.de X-Host-Fingerprint: 212.227.17.21 mout.gmx.net Received: from [212.227.17.21] ([212.227.17.21:59593] helo=mout.gmx.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B7/A5-05482-6158CD55 for ; Tue, 25 Aug 2015 11:09:11 -0400 Received: from [192.168.0.100] ([88.134.66.33]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MFLmC-1ZXbMt0Kiy-00EQjK; Tue, 25 Aug 2015 17:09:07 +0200 To: Sherif Ramadan , Nicolai Scheer References: Cc: PHP Internals Message-ID: <55DC8516.2010508@gmx.de> Date: Tue, 25 Aug 2015 17:09:10 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:NLBCRoktiVqfnbogcGyKFVNXPUDN0bkUUy2fnX7Gtnb+GoiDCAK EUm5q5T7Oh8keIzQus5E3CaBar7tyLUsi5irP2u+5tOCVHNNam1Alfh67i1l+cwP08xDLHm c2dU/1QYxvgXANO7sNnuApEexZujt/0qC25edaP/qJwhwzzPRf7CknPGA8GQSqpuZvdCqqV 7m6ijmTwu+FX88YcZphZA== X-UI-Out-Filterresults: notjunk:1;V01:K0:3xY1dMGC9Ro=:YIyZ6TeRggaPdP2t0TT++M IkThpMR2irsshrHfOIR0WwrziCLE4GnN/b38b+pDS6jd/t4tthQUirRC/EQfcXbtYVh/VKkhk cyOyqwehv7cuXXW6ACHcQ2E2hVBrd8tOYid/zNbePOOBfeyJ+eQRkwi0zk4wJquLf/Z1GHR8H FE5fMmARx9ZaMXYCjwtkNGUTJZ7qTlt67lAR5XBL7V7YsAMBQ0SeSkOFkEv3+IoKxImTN+pPG HKMZWL0JjlESCh+uwHR8KPHKM+QiLsCfM8v3zaR6TeJMVxZQIp5zdtT0tr5mJcjOQ4QazQeHW hUyFcboDMjWDPooARAWIWAktzmXpyB28vwoht/B6tNg7AJQp4BVHodw9PwJNFgDzht9DAF1q7 XTm81tLnNoHlqz9AX9ucazRFNC9eXPBqhRFQRmiJA7ONsKZipBacJtC0LK3G/hwVkjCfRTq2Y L25wJYTV5Tcx3Rs5DCWu8udyG5Wf8UVkNNdkSQHJDX1zLT/eEEhwu7MkmdpUhdzxbzv/L9VQS dusviYGeI8BLwbi+qy7LzXoXCV1s6nmjareOiQeqgB9+dD+3r/8RT/y5+qa264Bvxnb2Mzt5B ujZXb4//qSU1dGL1reH6oH6oADe/UadbGkNtW4pLEJV5iE/H6hqou+E9t8P8+rCQDi2bMRDLZ q6l76Pp6rCjYmb+ZMF4M9iEY/qIoQjAGgL+VBOB/LRDN+1MbmuRD9Wj64VYEknfdmg+OxIFO4 tLJEPVQ27mIRhwAUf6gI9xmWrCf658gvtvSRJA== Subject: Re: [PHP-DEV] Notice on non existing array key (on a boolean) From: cmbecker69@gmx.de (Christoph Becker) On 25.08.2015 at 15:48, Sherif Ramadan wrote: > You're right. The notice is triggered by array_push behavior only, which > means that $x = true; echo $x['foo']; doesn't trigger the notice, which is > the same as your code above. Only write operations have historically > resulted in this notice. > > I would agree that providing the notice would help someone debugging > potentially buggy code like this. Not sure if this is something we can > squeeze into 7.0.0 release at this point, but I would consider it a bug fix > with BC rather than something that should be subject to current feature > freeze. See also . > On Tue, Aug 25, 2015 at 9:35 AM, Nicolai Scheer > wrote: > >> Hi all, >> >> I'd expect the following code to throw a notice/warning: >> >> $x = true; >> $y = $x['foo']; >> >> It executes completely silently. >> $y is NULL afterwards, which is expected, since the right hand side of >> the assignment is undefined. >> >> If $x was an array (e.g. empty array), a E_NOTICE would be emitted. >> >> Can anyone shed a light on this behaviour? If accessing non existing >> array keys is worth a notice, shouldn't accessing an array index on a >> non array be worth a notice as well (maybe even a warning)? >> >> The other way round emits a warning (i.e. writing to an array key on a >> non array): >> >> $x = true; >> $x['foo'] = 'bar'; >> >> Warning: Cannot use a scalar value as an array ... >> >> Thanks for any insight, -- Christoph M. Becker