Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:69189 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72694 invoked from network); 18 Sep 2013 12:57:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Sep 2013 12:57:46 -0000 Authentication-Results: pb1.pair.com smtp.mail=leight@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=leight@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.174 as permitted sender) X-PHP-List-Original-Sender: leight@gmail.com X-Host-Fingerprint: 74.125.82.174 mail-we0-f174.google.com Received: from [74.125.82.174] ([74.125.82.174:36982] helo=mail-we0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C1/56-43258-943A9325 for ; Wed, 18 Sep 2013 08:57:45 -0400 Received: by mail-we0-f174.google.com with SMTP id q58so6336853wes.5 for ; Wed, 18 Sep 2013 05:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=URChvjzmRSJIdvKsHIYpqpcxHQoFDWhmRzQ+gzNaNj0=; b=LXa7jTuV2kqOnpfmHsqKKxUCF/oyX851tJzuiaBgZfXGvFcKlRoL2y0KN18xWb4Htt mZfEAKe/meFU6whWFOAcfAh38B2DmL0i5MkKMJaA0qKpZKk5KiWc37yecnwVD+FfAYLY 1uBiWLVdbJUscpZb6GOx5B14xf0HAtqc+7bLOyb+5byGYp52D+0sCZGkq0vfzH92Hz5r Kq0JDK/cOlo5qsoJJg9lqMII8lSQMTke4kcDYAEOUpyJLZRhyl/YL9vptaUBFiTOnUeD QMKwT2FtKww48vGIIT9jfm1OpQPtp4062j+AbCi3bjCDMdKfgTKzv0IVDefODN2/hAIT Gozg== MIME-Version: 1.0 X-Received: by 10.180.89.147 with SMTP id bo19mr7067365wib.3.1379509062997; Wed, 18 Sep 2013 05:57:42 -0700 (PDT) Received: by 10.216.184.3 with HTTP; Wed, 18 Sep 2013 05:57:42 -0700 (PDT) In-Reply-To: <52399abd.070a0e0a.1dad.5877SMTPIN_ADDED_BROKEN@mx.google.com> References: <52399abd.070a0e0a.1dad.5877SMTPIN_ADDED_BROKEN@mx.google.com> Date: Wed, 18 Sep 2013 13:57:42 +0100 Message-ID: To: Frank Liepert Cc: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: [PHP-DEV] Allowing is_* functions to accept multiple parameters From: leight@gmail.com (Leigh) On 18 September 2013 12:15, Igor Wiedler wrote: > > for is_* functions, this could easily be done with a higher-order "every" function. You pass a predicate and an array of values. It returns a boolean. > > Example: > > if (!every('is_int', $numbers)) { > throw new \InvalidArgumentException(...); > } > > Not only is that much cleaner in my opinion, it also is composable without having to change *all* of the is_* predicates. Might just be me, but I don't really like having function names as strings (obviously I use it when I _have_ to, but I try and stay away from it otherwise). Feedback I'm really interested in is what issues could arise from changing those predicates. I'm pretty short sighted in this regard, and mainly see the benefits I would gain from this change, so looking for more "This is a terrible idea because..." kind of stuff. On 18 September 2013 13:21, Frank Liepert wrote: > > Returning bool in this case will make it impossible to respond with a > meaningful error message. Which of the provided arguments !is_int()? I agree that it doesn't fit every case, and it's not supposed to. The same can be said of isset(), if it is important to know which argument was not set, then you have to use multiple calls. On 18 September 2013 13:21, Frank Liepert wrote: > > Finally, the imho best solution would still be introducing optional scalar > type hinting. But that is another topic and shouldn't be discussed here. I agree, (both that it would be better, and that it is another topic entirely - one which usually goes in circles, so lets stay away from it here :))