Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102780 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 75380 invoked from network); 11 Jul 2018 23:04:41 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2018 23:04:41 -0000 X-Host-Fingerprint: 85.230.241.5 c-05f1e655.79-4-64736c10.bbcust.telenor.se Received: from [85.230.241.5] ([85.230.241.5:24052] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 59/92-57182-80D864B5 for ; Wed, 11 Jul 2018 19:04:40 -0400 Message-ID: <59.92.57182.80D864B5@pb1.pair.com> To: internals@lists.php.net References: Date: Thu, 12 Jul 2018 01:04:36 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 85.230.241.5 Subject: Re: [PHP-DEV] [VOTE] array_key_first(), array_key_last(), array_value_first(),array_value_last() From: ajf@ajf.me (Andrea Faulds) Hi, CHU Zhaowei wrote: > I voted no. > I don't think we have an agreement on dealing with non-existing value, and the way this RFC proposed, just returning null without any notice/warning, is wrong IMO. I know we already do this in other array_* functions, but we cannot keep making mistakes just because we already made same mistake. > > Regards, > CHU Zhaowei > Hmm. Returning null with no warning makes perfect sense for keys, since null is not a valid key so there's no ambiguity, but for values it seems problematic. On that ground I've decided to change my vote to No for the value functions, but keep the vote for Yes for the key functions. Someone who wants such behaviour could always do ($array[array_key_last($array)] ?? null), I guess. -- Andrea Faulds https://ajf.me/