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.

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

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

And yes, everything is `final` to ensure that nobody can do anything
with the classes. This applies to the `UUID` and the `UUIDParseException`.

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. ;)

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to