Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:99159 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47432 invoked from network); 24 May 2017 18:47:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 May 2017 18:47:35 -0000 Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.128.169 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.128.169 mail-wr0-f169.google.com Received: from [209.85.128.169] ([209.85.128.169:33322] helo=mail-wr0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 15/20-10292-645D5295 for ; Wed, 24 May 2017 14:47:34 -0400 Received: by mail-wr0-f169.google.com with SMTP id w50so60209800wrc.0 for ; Wed, 24 May 2017 11:47:34 -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=Tjjctc5EGt+9+mLveD1zxI7etwPVPzbkfrZSFhoZvB8=; b=HNVO7R0Mojz6oissB6oV83YFeBw9gKH/YF1M1sHOkXK+WloWmoy2tMPtkGdsjH7o/o AsvLO/PnAxcDyc39FVKWGEa7pQp4M7osA0QIRBE3Xla+IK4LySgGLVid+R+mFAyUdJXP pmLtyudHOtpy8QJlgmp3TgiNnJfO7gEUDJVMD93p7opkLRjg0UcQZeO2d3g3EZK63KTQ sxT0ypu1Hf/+aygNzdZG/rHAZkO7cP1QBSB+ES05N0pEKRUwi9IJmrPB3SRmdIwJqcQX CLn2lzDIZ84lVqjajJ8YDcow7+cUK9uadv4oWprpHoVbkYJWrq7POa0uNRHMblHOgRw4 WEoQ== 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=Tjjctc5EGt+9+mLveD1zxI7etwPVPzbkfrZSFhoZvB8=; b=mzjvPjlcNuCoAbpeJlxfPpToJGXVKwy6KCSxKJsZxKQlCw3MQuVC/GBZQAm5rb6UsJ u0LJ8kz7gv0NX0blW3lq3g6duYrspx1ovMn0umUpo2JXOveCBTdUkSQHtgiYJuUFQqwr iQP3E7ySNlYfLP+U2OrL3MTUOjGi+gkFQb5kuVFgnV+LOebr+oV944iWHbm3VDAVaqAT kUlKgKBwhon6SQt1dTt86n1//fDZPN/nSevZGc6pWAK5+KkIGcVB9OEiSz8nQrEs1j3T ok/gHVOtWx0DMT+xzv5mqyXDdyKIDZePW/kr8FbpB7Fqcf797kNzPJT9zeo61MtZ1cxL exPg== X-Gm-Message-State: AODbwcDPa0S5KaiGxX7UixOpcb+3uIIZMm+J8giN4j2xi5rpCQ0+adUz M5wasUomuAdKSOmF+lZIZZiZZuimqA== X-Received: by 10.223.142.50 with SMTP id n47mr20380359wrb.188.1495651651843; Wed, 24 May 2017 11:47:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.161.147 with HTTP; Wed, 24 May 2017 11:47:11 -0700 (PDT) In-Reply-To: References: Date: Wed, 24 May 2017 20:47:11 +0200 Message-ID: To: Fleshgrinder Cc: php-internals Content-Type: multipart/alternative; boundary="f403045f50d66a7ccc05504989b6" Subject: Re: [PHP-DEV] [RFC] [Discussion] UUID From: ocramius@gmail.com (Marco Pivetta) --f403045f50d66a7ccc05504989b6 Content-Type: text/plain; charset="UTF-8" On Wed, May 24, 2017 at 8:39 PM, Fleshgrinder wrote: > On 5/24/2017 8:09 PM, Marco Pivetta wrote: > > For once, I must say that I disagree with having an OOP API defined in > core. > > This can exist in userland, so it probably should. Internal classes, > their > > reflection, behavior, inheritance model, etc are full of quirks. > > There's nothing wrong in returning a string, then having a userland lib > > make it into a UUID value object: it actually is better for everyone's > > sanity. > > It would (probably) be better to stop at the function that actually > > generates the identifier, then having the boxed value defined in userland > > anyway. Yes, we lose the type hinting, but damn are internal classes > ugly. > > If you must keep the object style, make it `final`, so at least we won't > > have people extending this thing for no good reason at all :-P > > > > Marco Pivetta > > > > The problem with procedural APIs is, especially with the way the PECL > UUID is implemented, that you are constantly converting back and forth. > While OO allows you to encapsulate your things. > Yup, converting is indeed problematic. > There is actually only a single thing that is not (yet) possible with > Reflection on internal methods: getting the default values of a > parameter. I wrote Reflection tests for every single thing, to ensure > that it works as good as possible. Have a look at the `definition.phpt` > test cases: > > https://github.com/Fleshgrinder/php-src/tree/rfc/ > uuid/ext/standard/tests/uuid That's actually awesome! Well done, this pretty much nullifies my fears > Here is one where I had do comment the default value thingy: > > https://github.com/Fleshgrinder/php-src/blob/rfc/ > uuid/ext/standard/tests/uuid/UUIDParseException/__ > construct/definition-005.phpt#L15 Ok, this is inherited API that is broken in all libraries anyway due to default value reflection, so I guess it's good to go. > > > And yes, everything is `final` to ensure that nobody can do anything > with the classes. This applies to the `UUID` and the `UUIDParseException`. > Thanks! > > Furthermore, I carefully crafted everything to be as close to userland > as possible. No magic, none at all. I use default PHP built-in stuff for > everything. Even the parameter parsing is 1:1 as it would be if you > would define the very same class in PHP. > > I will extend my signature with "No Magic!" now. ;) > Perfect, this absolutely makes it a huge :+1: on my side. Last thing I'd suggest is to grab Ben Ramsey and get him to check the patch :-) Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --f403045f50d66a7ccc05504989b6--