Le dim. 27 avr. 2025, 22:32, Tim Düsterhus <t...@bastelstu.be> a écrit :

> Hi
>
> On 4/27/25 22:30, ignace nyamagana butera wrote:
> > $url = Uri\WhatWg\Url::parse("/foo", ".com");                 //
> > Throws Uri\WhatWg\InvalidUrlException because of $baseUri
> >
> > Since parse is used shouldn't it return null instead of throwing ?
>
> In this case the `$baseUri` is invalid. Since this is not expected to be
> an untrusted value, it makes sense to me to throw an
> `InvalidUrlException` here. The `null` return should only be used for an
> invalid `$uri`.
>
> Best regards
> Tim Düsterhus
>

Hi,

I understand that but then I fail to see the added value of the parse
method vs the default constructor since from the RFC the only difference is
that the parse named constructor should instead of throwing return null. If
the parse method can still throw from a consumer POV it looses much of it's
utility. If I really want that level of knowledge using the constructor
should be the only way to go AFAIK.

Best regards,
Ignace Nyamagana Butera

>

Reply via email to