Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:62760 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16254 invoked from network); 3 Sep 2012 17:46:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Sep 2012 17:46:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=theanomaly.is@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=theanomaly.is@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.170 as permitted sender) X-PHP-List-Original-Sender: theanomaly.is@gmail.com X-Host-Fingerprint: 209.85.217.170 mail-lb0-f170.google.com Received: from [209.85.217.170] ([209.85.217.170:58360] helo=mail-lb0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/53-20751-BFCE4405 for ; Mon, 03 Sep 2012 13:46:36 -0400 Received: by lbbgp3 with SMTP id gp3so2709493lbb.29 for ; Mon, 03 Sep 2012 10:46:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=88cQUbfHo9L2K+FlibNbI9mdikucGBzrxShK3oj0m14=; b=ZPMMrGYLomv4qU996LnM2/U9BgTkMVVeLqblJoJtbTCu2ZrmrMDyh7R5Kiwqk0pDcX W0e5xfnUl1+Akxq1F+DVr5s83cze3J5DIJx8cAf4Jl/J8ZI1pQNhW5ehvmQu1NdBDJg+ tj4VRpV+X6jOv1CQi66B/vnaRdWPKyAuIHvFz+oQ5os2PBv7m5UNMq0BJILOwBo5bdh4 hAPn/BNE0Z3PlIUj4gbAN9IPlcS9U/+X51QGRKRsUX50dvDM96HvY0nIrrfy2FRqX+jf 5UhiDj8ClXGmMbnM+D8z4sWPl+FoJRfrHtBhy8dUD6ryBSN+V0HYV92fRC9ApaJmaTYL Z4yg== MIME-Version: 1.0 Received: by 10.112.88.2 with SMTP id bc2mr3963823lbb.61.1346694392652; Mon, 03 Sep 2012 10:46:32 -0700 (PDT) Received: by 10.112.12.178 with HTTP; Mon, 3 Sep 2012 10:46:32 -0700 (PDT) In-Reply-To: <5044EAB4.40003@ajf.me> References: <20120902230741.TSGJ23973.aamtaout03-winn.ispmail.ntl.com@p2> <5044EAB4.40003@ajf.me> Date: Mon, 3 Sep 2012 13:46:32 -0400 Message-ID: To: Andrew Faulds Cc: Derick Rethans , Laruence , Jared Williams , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Foreach list behaviour From: theanomaly.is@gmail.com (Sherif Ramadan) On Mon, Sep 3, 2012 at 1:36 PM, Andrew Faulds wrote: > On 03/09/12 18:35, Sherif Ramadan wrote: >> >> On Mon, Sep 3, 2012 at 4:20 AM, Derick Rethans wrote: >>> >>> Ew, that's quite nasty (in both cases). Is there a way how we could turn >>> those into a notice or so? >>> >>> cheers, >>> Derick >>> >> Sorry, hit reply instead of reply-all... >> >> list($a,$b) = 1; >> var_dump($a,$b); >> /* >> NULL >> NULL >> */ >> >> This doesn't throw notices anywhere else... why should it throw >> notices in foreach? I guess the only logical answer would be to notify >> you if you were using scalar values with foreach and list, but then we >> don't notify you if you're using scalar values with list anywhere else >> in the language anyway. I'm starting to see huge inconsistencies with >> how list is being implemented in foreach. >> > Possibly more importantly, since 1 should cast to, er, [1] (I think...), why > is $a === NULL? > > -- > Andrew Faulds > http://ajf.me/ > It should absolute not cast anything. list($a, $b) = $c; is the equivalent of saying $a = $c[0]; $b = $c[1]; In this case $c just happens to be a scalar value and as such you can not derive anything from the scalar value in that context. It is implicitly null.