Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82129 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42034 invoked from network); 8 Feb 2015 09:26:37 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Feb 2015 09:26:37 -0000 Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.216.180 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.216.180 mail-qc0-f180.google.com Received: from [209.85.216.180] ([209.85.216.180:54628] helo=mail-qc0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 52/A2-24707-BCB27D45 for ; Sun, 08 Feb 2015 04:26:36 -0500 Received: by mail-qc0-f180.google.com with SMTP id r5so18335164qcx.11 for ; Sun, 08 Feb 2015 01:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=fN2xug7IkjAVzVny/h4bNJhkjL7AZ67yme4M6UbsLVE=; b=UZgxH62qSZHu1r0RDYOh6Lm9AndZT41zG/fI+sLwpo9zEdlX6QXE/301sXgkl+sPh9 0uWOuu05vU/LR1UPp/Q9atOc+fvNe1YxpKkGGRV28CTWgR5mjaNk0JW4JOMcLNtykECD ZwRJMpicawKH66bjULigbgDJc4Rftfh7L44t+jC+9PO6Cn/a68/E4Ic4DKQEt+rpr9qe M/8a5GItXI3HVo4k8/kVJAYDjra5Hgyq+uB3gTrF/8RKZLzo9OtSzhdEHqw6rE05lXmm bpEXy79OqIR/GOtHQ3Hpxn4vY2xFhN8W1OadAiHGEPi/oaPo6ObW8TzKhwMKu3QQ34jl i4oQ== X-Received: by 10.224.119.199 with SMTP id a7mr12137731qar.68.1423387592742; Sun, 08 Feb 2015 01:26:32 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.229.28.72 with HTTP; Sun, 8 Feb 2015 01:25:52 -0800 (PST) In-Reply-To: References: Date: Sun, 8 Feb 2015 18:25:52 +0900 X-Google-Sender-Auth: VpNCKCmR16pxJkXiGQZAPM19qPM Message-ID: To: Kalle Sommer Nielsen Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a11c2f9b4d7de1c050e903f8d Subject: Re: [PHP-DEV] Only variables can be passed by reference From: yohgaki@ohgaki.net (Yasuo Ohgaki) --001a11c2f9b4d7de1c050e903f8d Content-Type: text/plain; charset=UTF-8 Hi Kalle, Thank you for the list. It's very helpful! On Fri, Dec 5, 2014 at 4:58 AM, Kalle Sommer Nielsen wrote: > 2014-12-04 9:28 GMT+01:00 Yasuo Ohgaki : > > Any comments? > > > > Regards, > > > > -- > > Yasuo Ohgaki > > yohgaki@ohgaki.net > > I think we should solve these on a case-by-case basis, I can think of > one reason why the warning exists, and that is because it modifies the > array pointer and the argument is sent by reference. But I think we > can safely remove the warning if the parameter was not sent by > reference, as then we would expect the user to use the return value of > array_pop() to assign the value from. I don't think we should remove > warnings if you pass a statically value to it, sure some APIs can > return a variable length/dynamic array but then I think they should be > referenced into a variable and then passed to the function as they are > most likely going to be used later, I can't really think of a case > where it would be useful to send a return value of some API call to > array_multisort() and then use the boolean true or false to check if > it was a successful call for example.. > > For functions like next() that only supports taking the argument by > reference, this should remain (since the return value is the internal > array pointer position). > > I went over the manual and the following should remain that warning: > array_multisort() > array_push() > array_shift() > array_unshift() > array_walk() > array_walk_recursive() > asort() > arsort() > each() > ksort() > krsort() > natsort() > natcasesort() > reset() -- Debatable though (does not many any sense, but if current() > and family is, and this is not, it will make it inconsistent) > rsort() > shuffle() > sort() > usort() > uasort() > uksort() > Agreed. I would like to do like $var; array_walk(func(), function ($v, $k) use ($var) { $var .= $v.$k; }); though. > > > And the following can have the warning removed if the argument is not > passed by reference: > array_pop() > array_splice() > current() -- Debatable though > end() -- Debatable though (use array deferencing?) > extract() > key() -- Same as current() > next() -- Same as current() > prev() -- Same as current() > I think array_pop() array_splice() extract() These could be changed. First of all, removing warnings only for these is feasible in PHP7? We need Engine experts. Thank you. Does anyone object to remove warnings for these? Regards, -- Yasuo Ohgaki yohgaki@ohgaki.net --001a11c2f9b4d7de1c050e903f8d--