Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API

From: Date: Sat, 31 Aug 2024 00:10:15 +0000
Subject: Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Mon, Aug 26, 2024, at 2:40 AM, Máté Kocsis wrote:
> Hi Ignace, Niels,
>
> Sorry for being silent for so long, I was working hard on the 
> implementation besides some summer activities :) I can say that I had
> really good progress in the last month and now I think (hope) that I 
> managed to address most of the concerns/suggestions people mentioned
> in this thread. To summarize the most important changes:

I'm not fluent enough in the different parsing styles to comment on the difference there.

I do have concerns about the class design, though.  Given the improvements to the language, the
accessor methods offer zero benefit at all.  Public-read properties (readonly or otherwise) would be
faster and offer no less of a guarantee.  If you want to allow someone to extend the class and
provide some custom logic, use aviz instead of readonly and extenders can use hooks instead of the
methods.  The getters don't offer any value anymore.

It took me a while to realize that, I think, the fromWhatWg() method is using an in/out parameter
for error handling.  That is an insta-no on my part.  in/out reference parameters make sense in C,
maybe C++, and basically nowhere else.  I view them as a code smell everywhere they're used in
PHP.  Better alternatives include exceptions or union returns.

It looks like you've removed the with*() methods.  Why?  That means it cannot be used as a
builder mechanism, which is plenty valuable.  (Though could be an issue with query as a string vs
array.)

The WhatWgError looks to me like it's begging to be an Enum.

I am confused by the new ini value.   It's for use in cases where you're NOT parsing the
URL yourself, but relying on some other extension that does URL parsing internally as a side effect?
 

As usual, I am not a fan of an ini setting, but I cannot think of a different alternative off hand.

--Larry Garfield


Thread (152 messages)

« previous php.internals (#125367) next »