Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API
| From: | Paul M. Jones | Date: | Thu, 17 Apr 2025 20:47:46 +0000 |
| Subject: | Re: [RFC] [Discussion] Add WHATWG compliant URL parsing API | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127141@lists.php.net to get a copy of this message | ||
Hi Maté and all,
A one-off comment about the exceptions:
The RFC posits that _Uri\UriException_ extends _Exception_, and _Uri\InvalidUriException_ extends
_UriException_.
However, pre-existing userland solutions to the URI problem lean more heavily on the native PHP
_InvalidArgumentException_, which extends _LogicException_. (Cf. <https://github.com/uri-interop/interface/blob/1.x/README-RESEARCH.md#exceptions>.)
(_LogicException_ "represents an error in the program logic. This kind of exception should lead
directly to a fix in your code.")
As such, the _InvalidUriException_ would better extend from _LogicException_.
What then to do with _UriException_ ? It's a base, it never gets thrown anywhere. If a base is
actually necessary, perhaps it should be renamed _UriLogicException) and extend _LogicException_;
then _InvalidUriException_ can extend from that base. This leaves room for a _UriRuntimeException_
base, should one ever be needed.
-- pmj