Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:94880 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 96799 invoked from network); 6 Aug 2016 11:02:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Aug 2016 11:02:18 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.177 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.213.177 mail-yb0-f177.google.com Received: from [209.85.213.177] ([209.85.213.177:33920] helo=mail-yb0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 73/18-33134-8B3C5A75 for ; Sat, 06 Aug 2016 07:02:17 -0400 Received: by mail-yb0-f177.google.com with SMTP id x196so22384485ybe.1 for ; Sat, 06 Aug 2016 04:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=ilWhKU9ZjHMQffwHP4ReuUYFMddpvQA3ytmAugJKE5g=; b=ak96kmnRjCVB7DaZRYq6EPYq8ci9XFduyES6KbCs11cB09IrCqzL3g29jb617JT4fc 0kIp8WsheuQJ2WKgTB0ycz92vvMknQvVG0IVB9NYxRftv1qYhz4ywhM4fCfWxAJL3dV0 yw+UK2SMLO3/dcAoYLh0hZjkB9J4JlUrMpB3nD4GoWd7PHuDOEeAiQPGbga8I4TryBsU YPDxhGXvSvxH0+5r00HuLQRvQcGRyyiAe01T0UR3JzvyBW2hoI2oP1xq5QuLlb/D6w6p 0VxROjzW9bnHWtrKpOUpkEDRbjdX8zdHRsxqXhmUmQpAXAN5+Ao1xC03n+G+aNQzjNH8 UuFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=ilWhKU9ZjHMQffwHP4ReuUYFMddpvQA3ytmAugJKE5g=; b=lAgDfgzAbm3rMaOpKHHknZHp+eS4kDDjOIWxBgyCpH5dYTquALN7QRwKlc6Jfb1PNT ANCIN9HAN14ynuMfukbsXzJWwXMJ5IsAErws7vabMEEmBWYTwPxSaAaPBxQdNEdM0sbE LElPVcxrgC3sgIxvCVqtOWMGoay2pcYj+hZIWeqbL+97Kk+khE8do889KvmmqQyJEYRg WzwpaYoN6otqLk7Z6lL/pCW6WsuudSeL3qwusPsqTxsjBKfINmkx5lCKHrbTa76xy6nz tFOwb8yLjAXjwjvKln1JllNUGUpB36Raxd9wLbEqmcufL+bm5Cd190JgCR4AhUwn3b7j qxfA== X-Gm-Message-State: AEkooutscPUHA7+sQVo9U9icqL7NYM9zz8nEPTz77RlWdSLBFdgAcisZAtTQYG28tjPH4wwt6LLBAeoxiNZlpQ== X-Received: by 10.37.59.214 with SMTP id i205mr4149352yba.75.1470481333601; Sat, 06 Aug 2016 04:02:13 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.131.129 with HTTP; Sat, 6 Aug 2016 04:02:13 -0700 (PDT) In-Reply-To: References: Date: Sat, 6 Aug 2016 13:02:13 +0200 Message-ID: To: Davey Shafik Cc: "internals@lists.php.net" , Dmitry Stogov Content-Type: multipart/alternative; boundary=001a114f436c89c9bb0539651df5 Subject: Re: [PHP-DEV] Change to Too Few Args Exception RFC From: nikita.ppv@gmail.com (Nikita Popov) --001a114f436c89c9bb0539651df5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Sat, Aug 6, 2016 at 11:53 AM, Davey Shafik wrote: > 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 excepti= on >>> class for this error: >>> >>> `\TooFewArgumentsError extends \Error` >>> >>> A use case where this may trivially occur is where you are using argume= nt >>> 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 th= e >>> 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 tha= t >> 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? > Forgot to mention, this is only for strict_types=3D1, or if zpp explicitly opts to throw (e.g. constructors). Nikita --001a114f436c89c9bb0539651df5--