Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94878 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90324 invoked from network); 6 Aug 2016 09:53:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2016 09:53:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@daveyshafik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@daveyshafik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain daveyshafik.com from 209.85.220.175 cause and error) X-PHP-List-Original-Sender: me@daveyshafik.com X-Host-Fingerprint: 209.85.220.175 mail-qk0-f175.google.com Received: from [209.85.220.175] ([209.85.220.175:36403] helo=mail-qk0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 18/F6-33134-B93B5A75 for ; Sat, 06 Aug 2016 05:53:31 -0400 Received: by mail-qk0-f175.google.com with SMTP id v123so151435033qkh.3 for ; Sat, 06 Aug 2016 02:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daveyshafik-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=sqUJ+lArxVSZeNONIeNctUKQwo8eorBu80JZK2PTrEY=; b=xl0rI3hsLZ+BxU6U7jxheTgoyIPBhho64KR+kKx+B59cjVRxu/A4oSbA9oy/yqrc7t WbTNRJmRH6weK0dGJEIE2cxQ/mKYOI6ag8r4ZJrKIZu/Q+RuuMcYihAGDGBgl58IKgWl zgn7lAQQBRYEvswppkYjHgsNqWzaSC9LdqT/zZyhsD8eS6Id5L4e1IyeO1c6tZlcgbF3 QnxaPv+hYMaTXLs0TFn9iDF2CI7auAqJ06xAKWVEnfl1YATeasVTwFMbNMrHljmxJSDR 7BTtFOZE68nbfxPlQtoWbVGv5SAQ0DshuEyvYivEB58amwWKugCDEd2iuiQ6tY2Ke2mo w0cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=sqUJ+lArxVSZeNONIeNctUKQwo8eorBu80JZK2PTrEY=; b=MAd+jnqhTWM61sp0XXSfL3B0heeA0B9quP3c0Vc31NZheTY+Ribz0hK3MLLho+jRoS 5ZCAFs/7kCG30Oe0UwV2R/88unTR9dUmlLv6MqupSpR0n3QHskTqmLNtMUx6fVkwXVT0 emUh7hN8vAXCaTFMcQwS348+esEBwEz8kQXbMWRYE8wSF74DOLuSlKAecwwL2bKceG5r luVTzD/Vju0+hMwClKY9oRmj73fjxWGzGsopALH3X/hoJGvq3px4U5RUM4YM4blLz3s/ i86RYtRt4tFhh6SL8JOUfljDUq3M56aCpUX//1pK8TxrcgGVtfBOU6enuHoz8ers8HL7 9J5w== X-Gm-Message-State: AEkooutAr3cPuySj6vCBiDbjqZxADWHfMTlTo+X6N2uL07WJemQ9+tcuvN221SWdo1TWjOxE2acgmHOyo2hf4F7C X-Received: by 10.55.185.131 with SMTP id j125mr16760904qkf.138.1470477207797; Sat, 06 Aug 2016 02:53:27 -0700 (PDT) MIME-Version: 1.0 Sender: me@daveyshafik.com Received: by 10.237.55.138 with HTTP; Sat, 6 Aug 2016 02:53:27 -0700 (PDT) In-Reply-To: References: Date: Sat, 6 Aug 2016 02:53:27 -0700 X-Google-Sender-Auth: tWYBmlK4uawdv1jTjhHgCC-oohM Message-ID: To: Nikita Popov Cc: "internals@lists.php.net" , Dmitry Stogov Content-Type: multipart/alternative; boundary=94eb2c0490789f128605396427f4 Subject: Re: [PHP-DEV] Change to Too Few Args Exception RFC From: davey@php.net (Davey Shafik) --94eb2c0490789f128605396427f4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Aug 6, 2016 at 2:34 AM, Nikita Popov wrote: > On Sat, Aug 6, 2016 at 4:26 AM, Davey Shafik wrote: > >> Hey all, >> >> I know this is a little late in the process, but it's something I've >> noticed while prepping some content around 7.1. >> >> This RFC: https://wiki.php.net/rfc/too_few_args >> >> Passed, and has been implemented, but I feel that throwing an `\Error` >> exception is a mistake. I think we should another more concrete exceptio= n >> class for this error: >> >> `\TooFewArgumentsError extends \Error` >> >> A use case where this may trivially occur is where you are using argumen= t >> unpacking and the unpacked array is too small. Writing this, just looks >> bad: >> >> try { >> foo(=E2=80=A6 $args); >> } catch (\Error $e) { } >> >> compared: >> >> try { >> foo(=E2=80=A6 $args); >> } catch (\TooFewArgumentsError $e) { } >> >> Thoughts? Dmitry? >> >> Given the tiny change this is, and that is backwards compatible with the >> original RFC, I would like to add this to 7.1 for beta3. >> >> I think I can make this change myself. >> >> - Davey >> > > Problem: We already use TypeError for this for internal functions. If we > want to introduce an extra exception for this, lets use it for internal > functions as well. In that case we should probably go with something that > applies not just to too few arguments, but also to too many. > Are you saying that in PHP 7.0, if you call an internal function with too few, or too many arguments it will emit a TypeError exception? Can you provide examples? It's obviously not every function, e.g. fopen() emits a Warning if you forget the second arg. With that in mind, to make this BC, TooFewArguments would have to extend TypeError which isn't great. Maybe, "ArgumentError" and the message will make it clear if it's too few or too many? - Davey --94eb2c0490789f128605396427f4--