Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99197 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94761 invoked from network); 26 May 2017 09:00:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 May 2017 09:00:24 -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.214.68 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.214.68 mail-it0-f68.google.com Received: from [209.85.214.68] ([209.85.214.68:35379] helo=mail-it0-f68.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2D/92-10292-6AEE7295 for ; Fri, 26 May 2017 05:00:22 -0400 Received: by mail-it0-f68.google.com with SMTP id 67so872170itx.2 for ; Fri, 26 May 2017 02:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=jZjcooUvbXoGQxQLaZytIT+afalQHhaOMePaqmOeEUo=; b=uGQLYyazgCUY2NdInb76uMHA5KZbV+QDP92FO8MAdiTDawLEeel5B9gGcnKRxyNobk scorLGOoQ0wcOdSkk/c8IWPs0PNVJGcDAsZco6jO29fuAxTg7rTF0kRsGicM/6BI685U ZU7w0Db+BnKGClqgs0zHtbDNE4sfuxqMY7hk8kGqPakLBN2lQDbFNfO9LPg1JN8jGGb/ dCcTL2yIB8zcXSVYMBZ3rOcChkR1uNx2FyzU5q7PBag/e3vpkgE6rryU8lcbnwKThN/G EQcvbv66C8KTkxGiJeHyyCxZv4+LnHY60GWFVh14dnF8v+4mIIcHWvVNDMtLZDGI1kk/ Pqig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=jZjcooUvbXoGQxQLaZytIT+afalQHhaOMePaqmOeEUo=; b=nrwEKR15XvVXfib1EbllenHzQAKT9+dBoKaiwCedDiSLVRi9uT7kaN0aCpC525wjz8 5RIF2IbA/OJRdevfKuhGlCQpcLas/EsHkZ9cxdO2h8+c+nx6LRgLEVW94OUBFYDbxas7 Z/00JDfmUuNa18TmHQPiqhbC8PPxuRYJDsZ1iA2+gcpB3um7NAoov4XAoehMRH+lBss6 yII7PNrFYmp2W1RTIn2KawhS3Zzl5oPb6Yn6+gQK9muPsfbgwKaezas0DHgdY8+MvyMZ lDViU9GE5bgD4/SFFUN1ivqXBUbw1rl9pJdTEilJ7Gtw7nzDrJwsenxLJicXKAp1hdJx IEOg== X-Gm-Message-State: AODbwcAW5gU+oqk/s/YDziaja+d9Fah0Na4zxPABf/ZVMMPRLQ3a18Yh 5jXPTK5gRoO15QQUGAx22XvUxegIww== X-Received: by 10.36.101.135 with SMTP id u129mr1681863itb.21.1495789219897; Fri, 26 May 2017 02:00:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.12.158 with HTTP; Fri, 26 May 2017 02:00:19 -0700 (PDT) In-Reply-To: <83c4075f-b694-4e83-fc09-4210e0091216@fleshgrinder.com> References: <83c4075f-b694-4e83-fc09-4210e0091216@fleshgrinder.com> Date: Fri, 26 May 2017 11:00:19 +0200 Message-ID: To: Fleshgrinder Cc: php-internals , Marco Pivetta , Kalle Sommer Nielsen , Larry Garfield Content-Type: multipart/alternative; boundary="001a114608221c688e05506991b6" Subject: Re: [PHP-DEV] [RFC] [Discussion] UUID From: nikita.ppv@gmail.com (Nikita Popov) --001a114608221c688e05506991b6 Content-Type: text/plain; charset="UTF-8" On Fri, May 26, 2017 at 10:34 AM, Fleshgrinder wrote: > On 5/26/2017 1:08 AM, Marco Pivetta wrote: > > Saw the discussion on github, and I wish that the argument parsing just > > behaved like a *NORMAL* PHP method. > > > > The following is perfectly valid: > > > > $crapTonOfUuids = array_map([UUID::class, 'v4'], range(0, 1000)); > > > > This would raise a lot of warnings if the API didn't behave like it does > in > > userland (warning on too many arguments). > > A point was raised about BC compliance when adding parameters (future > > scope), well here's the news: stop adding arguments to existing > functions, > > make some damn new functions/methods/classes (to whoever still thinks > that > > adding arguments is a valid decision). > > > > Well, I agree on the adding arguments part. I actually complained a lot > about this in the past. > > https://github.com/php/php-src/commit/49aed4fd75e9560444f63593b67fc4 > ed18e233c9#commitcomment-22277780 > > I added them because Kalle and Nikita really want to have them. Changing > the return types to be nullable is a complete no-go for me. I am sure > Larry would agree here with me. > To clarify, I certainly do *not* want the behavior that was implemented here. The correct way (in your specific case) to handle this if by using if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "") == FAILURE) { return; } or adding a zend_parse_parameters_none_throw() API. Of course this should not throw a warning and of course it should not return NULL, because that would be inconsistent with how the other UUID methods behave. Of course it should not allow silently passing additional arguments, because that would be inconsistent with both how the other UUID methods (with at least one argument) behave and with how PHP in general behaves. Nikita > > The approach I've taken right now would allow one to write: > > $crapTonOfUuids = @array_map([UUID::class, 'v4'], range(0, 1000)); > > As it would emit a warning, but still generate them. Well, unless you > have strict-types mode activated, in that case you would receive the > ArgumentCountError. > > I really don't know what the proper solution for this problem is. I > would just leave it out, as I did initially. Nothing bad can happen from > passing too many arguments; not enough should directly lead to an > ArgumentCountError, that's for sure. > > On 5/26/2017 1:08 AM, Marco Pivetta wrote: > > The UUID type and specification is simple and clear. > > Also, a UUID is a data type with no real behavior. > > The only possible and valid scenario for subclassing would be to add > > semantic meaning because the developer invented a new type of UUID: > that's > > to be excluded, as such an implementation (if relevant and secure) would > > land in core anyway in future PHP releases. > > Subclassing to alter behavior (generation/serialisation, if you want to > > call them "behavior") would be a mistake that could even lead to security > > issues, and it should be avoided. > > This class should be final, so keep it final, IMO. > > > > Marco Pivetta > > > > +1 > > -- > Richard "Fleshgrinder" Fussenegger > > --001a114608221c688e05506991b6--