Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94879 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94686 invoked from network); 6 Aug 2016 10:44:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2016 10:44:46 -0000 Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.219 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.219 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.219] ([81.169.146.219:20077] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C4/B7-33134-C9FB5A75 for ; Sat, 06 Aug 2016 06:44:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1470480282; l=6053; s=domk; d=kelunik.com; h=Content-Type:Cc:To:Subject:Date:From:References:In-Reply-To: MIME-Version; bh=HJ6l+sO0YWTy3p1DOgaz8/SElbkJpDk5Bo6QaQKMbMs=; b=UF22+eKKYTAJ60gUH9H39Wy+iDzIk1Vt21K8rhtEY7vZFoPht8/Zmh8hrG66QJPV5tO OzPE58r/Sjk/Af1ZYJhkNlAhwMoHoStDehen/WirunQQ0Apjj4v/O8nimwWXej4s6MVLl QkPxNtaFjXdeOl1+vHEKWyGo24hTZVyGLhE= X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mls2vWuiu+7SLGvomb4bl9EfHtOnc6 X-RZG-CLASS-ID: mo00 Received: from mail-wm0-f54.google.com ([74.125.82.54]) by smtp.strato.de (RZmta 38.13 AUTH) with ESMTPSA id h0557ds76Aigy26 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp384r1 with 384 ECDH bits, eq. 7680 bits RSA)) (Client did not present a certificate) for ; Sat, 6 Aug 2016 12:44:42 +0200 (CEST) Received: by mail-wm0-f54.google.com with SMTP id i5so68039747wmg.0 for ; Sat, 06 Aug 2016 03:44:42 -0700 (PDT) X-Gm-Message-State: AEkoouu1urnwjY6RbyUvAjEnKlRgzAsUXZzZsI02uXQVIZOyjAib4IuDXvDT3dPMPmZMywtZfcRJyWi2zIHVCw== X-Received: by 10.28.17.9 with SMTP id 9mr7618508wmr.73.1470480282062; Sat, 06 Aug 2016 03:44:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.27.206 with HTTP; Sat, 6 Aug 2016 03:44:41 -0700 (PDT) In-Reply-To: References: Date: Sat, 6 Aug 2016 12:44:41 +0200 X-Gmail-Original-Message-ID: Message-ID: To: Davey Shafik Cc: Nikita Popov , "internals@lists.php.net" , Dmitry Stogov Content-Type: multipart/alternative; boundary=001a11435ee2dc9fee053964de2f Subject: Re: [PHP-DEV] Change to Too Few Args Exception RFC From: me@kelunik.com (Niklas Keller) --001a11435ee2dc9fee053964de2f Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-08-06 11:53 GMT+02:00 Davey Shafik : > 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 > exception > >> class for this error: > >> > >> `\TooFewArgumentsError extends \Error` > >> > >> A use case where this may trivially occur is where you are using > argument > >> unpacking and the unpacked array is too small. Writing this, just look= s > >> 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 t= he > >> 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 w= e > > 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 th= at > > 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 > I don't like "ArgumentError", how about "WrongArgumentCountError"? Maybe also "WrongArgumentsError". Regards, Niklas --001a11435ee2dc9fee053964de2f--