Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102769 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49032 invoked from network); 11 Jul 2018 17:42:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Jul 2018 17:42:45 -0000 Authentication-Results: pb1.pair.com header.from=enno.woortmann@web.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=enno.woortmann@web.de; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain web.de designates 212.227.17.12 as permitted sender) X-PHP-List-Original-Sender: enno.woortmann@web.de X-Host-Fingerprint: 212.227.17.12 mout.web.de Received: from [212.227.17.12] ([212.227.17.12:33255] helo=mout.web.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AE/3B-15421-491464B5 for ; Wed, 11 Jul 2018 13:42:44 -0400 Received: from [10.129.18.221] ([194.76.42.30]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MVu1U-1fb6Ek0Y3s-00X4Lm; Wed, 11 Jul 2018 19:42:34 +0200 To: Levi Morrison , Christoph Becker Cc: =?UTF-8?Q?Bj=c3=b6rn_Larsson?= , mail@pmmaga.net, me@jhdxr.com, internals References: <13b4eb91-6566-3724-d45d-aa63254e1f58@telia.com> Message-ID: Date: Wed, 11 Jul 2018 19:42:31 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:uHJi4oEgTDDVwMuDL/Ad73QqZFB0jnM6K/Exsy/QP5ZbNTF2B2R 93wHHu9QAIYtDbLdVm49qZtRY0LvLLAHwVGKT8/q3zbqgS0QoxkhjSo7kbsYaVMxmIVzGmP rx5b0nYP0RyfrrxrlXiqk+tk7wy03TkbBHRRohEyzoHvmz7ZL+mW/A/pQ5/sDyLNIjMnbru WYBlE6SseCuZZgdkeR7+A== X-UI-Out-Filterresults: notjunk:1;V01:K0:eHvQK97m2DE=:BwylPJYQgbhHvGGAC1lXSl NCx9s9VpuGecuvfesidR3CPIbdDRu6GWP3ECXlGXRkwux0SaSL56WEGyrkAuEOOKS4uliEWpE ihfjp1OrXRRB4p//cWCZHNkrNFEHuSmo2L/ImD536wozc8glG5S9pcuzyCCERX0El2tQtQzv+ 9I0d7Dx2sWaeHeY/8hLSWy+YGrMaza34QJ4MkMlnHYaU4vFx+tMamp8GCUnJ0oTzOwMONEOft ngQB1WkkZNOvhLP/yDuwGuhmeAgyo0IRRW2s91cp1yifD4g5IG5NXolZf5m5/NMFt+gQJjdQ6 ocw7ISBofsKyKSb0+EA96OCdmka3fY2HnzSCYbFzL1IGHggt6SMMU/mAlYQjXU+wOpT218Q5U aATFaJ/3SXVhph4629+Axe1/bJaLFLPX1a2gw/SJ2skvG4KqbvY3tddxi7R18569XHmjgakCr IQhMD2ktTSX7JBgzu/h6vrRgkiDOp/VTmBcpyPrlhwuT/6DM/hxRAJMprb02kH5st8VGWJFBg l3JEN2544roTCiFCeKFlZ5kHS89T6H/Z3qYFVTiaL561t1V4WOanVvYN0JdK4GF1orN8GGZKC oGKuTlnTS+zQK+y7vcp1++zSchpjkWPzJ5g56AvhFlS3YJXTZ1WVD9vjQe5HswrvifJfVkLWn Isvd3dQ6X3pfX0wmQM9+Xb8ah1GfYxDAIxqhwkYm9W17dLzwuPv2HwqpVuvWxPFy7ZtemyUS1 PpJ8lzhJ3NQ0H/fV6n7JFXoBhg1zT9SIYGGUnhM1PxziXMnW4WnEbJbryWvzPPvxt6JAfOjfg I6Wu3R4 Subject: Re: [PHP-DEV] Re:[PHP-DEV] [VOTE] array_key_first(),array_key_last(), array_value_first(),array_value_last() From: enno.woortmann@web.de ("Woortmann, Enno") Am 11.07.2018 um 18:20 schrieb Levi Morrison: > As an example, it was claimed: > >> If I use a function I expect it to give me a return value which I can >> use without any further post processing $wantedValue = >> fancyFunction($someInput); > But this isn't true even for the array_value_* functions. There must > be pre or post processing because of error conditions. This was > pointed out by myself and others, but it was still ignored. > > This is what I mean by discarded, not discussed. In my eyes being aware of what I put into a function and thus catching non array inputs and empty inputs before differs a lot from post processing return values as it increases the comprehensibility of the code. I also can think of cases where the input format is known and no further checks are required. Additionally the tuple return pattern is not common among the PHP core functions and I don't know many occurences of this pattern in userland PHP code neither at the companies I've worked at nor at open source software/frameworks (correct me if I'm wrong) except the by far outdated old foreach construct with reset() and each(), thus I assume it's not a that common pattern for PHP developers to use it in core functions. As I pointed out during the discussion we should also watch at existing functions with the same problem, differ between a valid return value and an error. Not all of them can be changed to use different return mechanisms like the tuple return pattern (eg. array_pop). Maybe we can instead think about changing Z_PARAM_ARRAY_EX in a later stage to not return null in error cases but instead throw an InvalidArgumentException or something like that (at least for function calls with an empty array for functions which require a filled array, for invalid types maybe a fatal TypeError like it's thrown when a type hinted argument in a userland function is violated is the correct choice). Would be a pretty large BC breaking change but it would be consistent among the array functions. In my opinion neither rejecting the RFC nor changing it to return tuples solves the underlying problem.