Hi
Am 2024-08-26 09:40, schrieb Máté Kocsis:
Please re-read the RFC as it shares a bit more details than my quick
summary above: https://wiki.php.net/rfc/url_parsing_api
I have now finally found the time to go through the discussion thread
and make a first pass through the RFC and have the following remarks.
1.
The RFC is not listed in the overview page: https://wiki.php.net/rfc
2.
I agree with Dennis' remark that the `Rfc3986Uri` and `WhatWgUri`
classes must be final. The RFC makes the argument that:
Having separate classes for the two standards makes it possible to
indicate explicit intent at the type level that one specific standard
is required.
Developers extending the classes could accidentally violate the
respective standard, which nullifies the benefit of making invalid
states unrepresentable at the type-level.
This also means that the return type of the “withers” should be `self`
instead of `static`, which also means that the “withers” in the
interface must be `self`. Perhaps this means that they should not exist
on the interface at all. `DateTimeInterface` only provides the getters,
likely for a similar reason.
3.
I believe the `UriException` class as the base exception should not be
`abstract`. There is no real benefit to it, especially since it doesn't
specify any additional abstract methods.
See also the PR introducing the Exception hierarchy for ext/random for
some opinions / arguments regarding the Exception class design:
https://github.com/php/php-src/pull/9220
4.
I'm not sure I like the `Interface` suffix on the `UriInterface`
interface. Just `Uri\Uri` would be equally expressive.
5.
I am not sure about the `*User()` and `*Password()` methods existing on
the interface. As the RFC acknowledges, RFC 3986 only specifies a
“userinfo” segment. Should the `*User()` and `*Password()` methods
perhaps be specific to the `WhatWgUri` class?
-------
I'll give the RFC another read later and expect some additional
commentary when I think about this more.
Best regards
Tim Düsterhus