Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:104342 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 76074 invoked from network); 11 Feb 2019 18:57:05 -0000 Received: from unknown (HELO mout.web.de) (212.227.15.3) by pb1.pair.com with SMTP; 11 Feb 2019 18:57:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1549899584; bh=5BwmAiBr9NIgPo0u17FFC/L3NztLYueglcvxG+e16j0=; h=X-UI-Sender-Class:From:To:Subject:Date; b=CNeONRcHullpYpPpkvEVgDjNOJrdVpa1GSpxkPp1Usg5LEY8vDBNcBfRiEg+LvAit kPBursL233H5OyBC6J7+iqGqlf3P6yyBP9tQBlfTzlcX+PFykWzuWOrPpmBJ749muW /zxA64itBkT7dAx1Hb8UZWV5ObgQhbZAGef5Msj0= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from [10.129.18.221] ([194.76.42.30]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M0yzv-1hEKH10FN1-00v4ph for ; Mon, 11 Feb 2019 16:39:44 +0100 To: internals Message-ID: <5437a651-8263-49e9-b87e-d8d052d66c99@web.de> Date: Mon, 11 Feb 2019 16:39:43 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:W/xnJ6dbCPuWD1AaFZoKCbqYW7eomRVR7+rcXzWAhbSNvhOhz2p sdI7rKVY7HvGrcaCt4caunB3feY0sVdKeP0w9fKnuxfPAFIUqX0Mqcc28sd/ZgLqtX6VKYE 5wFt+dL9ypzTzyqiMNgTr/1C51K/ZUgRLTEp9oK5vN7ChOhKhjV859Wf8p4XHi6243FM3/S VJ81fZ0LJaaPXABKzASUw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:qnh7FmtdAnk=:oIY1z3s/Q+XzSUhh2H+wgz YBP2hD8XT5pDLsEYK4PEvtpxn/mB+bU+/1W9HGAuAKl/BMAbuYmyghPV0WtSIf7jg8OFV6UqG +iT3vgfBb3p1BaB4hQArwhSRtx/5EWP79Q+P4viV+Sdo3JoUPQ/lAs+xw/AVF40QCLY/H8zGy LgLQBstBeCu2gfOdFeznVwtGIPrzpnt8Bd58ihW8mHfs9o9m86JlgHC3Zzxc4IOtCgvUTmEaO 7/SSp3+UBnvOVu0yAzT25yJkvCfSTLNo0mC79kRSLcSNUiH+Uvng9afigfNQ7NdXKp00ekCkG cjK42qTK4ZXHjHf0d+LLeOz/qv4fVj6EzDf04smGQtGp9vr6MjQ/iUchvlfYCFjvtAkBylAUP 90bprqJzMFa+lzaRs9tf/B1P/2ymuptx7AoBGRg8z17wmXunLXgWWPb48BTgn3QHTsVxLkvQf bmpiXd2oHGGpf8A41TiTySv4kp+ljP9P6a9Ama/Rga9csmV2ujmbKm/swCkSO6aI+wyyn6SEm arl2n5Z0fSj9BFPdvk/CN6BGbJkLZMx4KKwdBzORWVyLb7UhrPCgieGAkjgasYBzjCHnBmu8K rHyygYTHCoi+koWcaIZ76ydOK34BUy4QtXukyKjNASzlDjuiEz+z19sl2GJcgdsPT/jij+k5O U1R36rUkRZVzEp9LwyYkhnB1i/upyb4tRz9cGzItqPUdpa3uC53qnwrbj3bRXkBYev46ZCsbx 7C1sTkjVnaWQwxyaDHsUhNx03XAnYV6R44PwqpUf7n7uGqSL0ro5s1JhBjuloMbt+HE5lLsuc Kft4BeK63lmbAiPlekUKDOYYbeUr4yswS0kHmqRKRhwJiqe7SIdVpKWrczQvQg+H0AfG83MgW il+Sa+i0HtFpoUNgeHZZ78gQQs5Q3bnDiUqFhNvBpjVq/5kIq72zeVWP2st5Hy4pPeRfeu76V QRow4Px5LKQ== Subject: Variadic is_*() functions From: enno.woortmann@web.de ("Woortmann, Enno") Hi internals, as I reviewed a bunch of code for handling data from different sources (eg. json) in the last days I stumbled over code like this multiple times: if (!(is_numeric($input['example1']) && is_numeric($input['example2']))) { if (!is_numeric($input['example1'] || !is_numeric($input['example2'])) { and I had multiple problems with this. * it's kinda hard to read * multiple writings for the same logic * ends up in complex conditionals I searched for discussions regarding this topic and found it was mentioned in a 'side thread' of the RFC for changing empty() to a variadic a few years ago (https://externals.io/message/82549#82641) and I'd like to collect some feedback if it's wothy to revisit the topic to write the above example as: if (!is_numeric($input['example1'], $input['example2'])) { Except the is_callable() method all is_*() methods could be extended with a variadic behaviour which would check the given values from the left to the right and abort if a value doesn't match the condition (in the example if a given value is not numeric). So all in all there are some points to talk about: Revisit the discussion? Which functions are reasonable to be extended? If all functions are reasonable: what to do with is_callable()? regards, Enno