Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83612 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 50286 invoked from network); 23 Feb 2015 21:36:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2015 21:36:11 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wg0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:39048] helo=mail-wg0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/F0-01128-B4D9BE45 for ; Mon, 23 Feb 2015 16:36:11 -0500 Received: by wggx12 with SMTP id x12so1475110wgg.6 for ; Mon, 23 Feb 2015 13:36:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=9LqgVVXSZhcmDfSaHS3Yrf7yrzKvt0rfzWkGGFK9gns=; b=Roxz+cFl34gtNfyHY2f1POlMiWm3qLEvDVeLLiOLszpQfvXZ9niCgZsV9cm+M9I8Xg 309l2JI1tzxZLvJUZcZHoF6h0shChmhaNeyQcO+YZIktNI1i7GynDXl0bg4ntaNeqO74 6J5rmVcnip/YR8CO6JUh4s/CMRQUqE0zGb52F3KZdI5mOvQG8S4/lw5Si0RkVC2ustpI SlDa3GwZnuwYVHwVlZPIArv9GBsPiC43m/BIWAsTSYaNfyVyMwGPscaHLIAu5gUTOjRX oIcpYvPF40QExjgOEFpLbwNlwi2SodErmuPMbMklzRggwMusIlN42PrlcOww1ewnMQpt GiHA== MIME-Version: 1.0 X-Received: by 10.194.2.75 with SMTP id 11mr26013183wjs.78.1424727368559; Mon, 23 Feb 2015 13:36:08 -0800 (PST) Received: by 10.27.10.168 with HTTP; Mon, 23 Feb 2015 13:36:08 -0800 (PST) Date: Mon, 23 Feb 2015 22:36:08 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=047d7b3a834cb47110050fc830b9 Subject: Mark some functions with PREFER_REF From: nikita.ppv@gmail.com (Nikita Popov) --047d7b3a834cb47110050fc830b9 Content-Type: text/plain; charset=UTF-8 Hi internals! With regard to my E_STRICT RFC [1] Yasuo and another off-the-record mail expressed a concern about the "Only variables should be passed by reference" strict standards warning. This notices makes sense in a lot of places, e.g. array_push(getArray(), 1, 2, 3); is totally pointless code if getArray() doesn't return a reference. array_push will just modify a temporary array in this case. However other usages like $top = array_pop(getArray()); are less clear: array_pop() both has a side-effect (removing the top element of an array) and a meaningful return value (the top element of the array). As PHP does not have a dedicated function for getting the first/last element of an array, many people use code like this (which currently throws E_STRICT) instead. I'd like to mark a few such functions with PREFER_REF (i.e. allow passing both references and values). In particular array_pop() and array_shift(). Does anybody have a problem with us doing this? Are there other functions which should use PREFER_REF? The motivation behind this is to make sure we only throw this notice in cases where the code is actually buggy/nonsensical instead of just making people ignore it altogether. Thanks, Nikita [1]: https://wiki.php.net/rfc/reclassify_e_strict --047d7b3a834cb47110050fc830b9--