Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79429 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77184 invoked from network); 4 Dec 2014 19:58:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Dec 2014 19:58:14 -0000 Authentication-Results: pb1.pair.com smtp.mail=kalle.php@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kalle.php@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: kalle.php@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-la0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:37122] helo=mail-la0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7D/81-61462-5DCB0845 for ; Thu, 04 Dec 2014 14:58:13 -0500 Received: by mail-la0-f43.google.com with SMTP id ge10so10269852lab.2 for ; Thu, 04 Dec 2014 11:58:09 -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:date:message-id:subject :from:to:cc:content-type; bh=wj5cEqGiSrBz9Ck+Z7W7wU0NhVubm8I9w0J3v0lQVLg=; b=tT5+0R2l2TOr+/MXUB00dAcxaEeEROSwRPTJJRkR7QLyx47NEm5akUOnLJMnK/4LvH hX5+V6uO3OGla+p7/oj9/3bba47xuC+vVd/Wt6w//cHfuTOMYdMjqorGPfmkhWLw8kmg AgzifCgh1ZXF9DK2ENZV6swSjl0C/0B8PMcEovBswzsldyiZfBtSI6eMkX5TAbA0tyVg ZOeYWIjFLvZ4nG3Axvk/ofAx9RKLD7uFTysyE/RDqkFiSjEr+IR/vavXxnNNSYkVccb3 OMg1eSucX1M6l9Gb+pXKhDcArAdpoas8q+kwk53McC8/IFvmpOCL+5ZsLqNMwKxpxotF 2J6A== MIME-Version: 1.0 X-Received: by 10.112.181.98 with SMTP id dv2mr11450602lbc.78.1417723089844; Thu, 04 Dec 2014 11:58:09 -0800 (PST) Sender: kalle.php@gmail.com Received: by 10.112.61.163 with HTTP; Thu, 4 Dec 2014 11:58:09 -0800 (PST) In-Reply-To: References: Date: Thu, 4 Dec 2014 20:58:09 +0100 X-Google-Sender-Auth: c4aOJUFONtoQ64g-lGX6rBghScc Message-ID: To: Yasuo Ohgaki Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Only variables can be passed by reference From: kalle@php.net (Kalle Sommer Nielsen) Hi Yasuo 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() 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() (Note, there is probably some I have missed, as I only looked for the &$array in the prototype of the functions listed above) Thoughts? -- regards, Kalle Sommer Nielsen kalle@php.net