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

From: Date: Sun, 27 Apr 2025 20:50:45 +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  Groups: php.internals 
Request: Send a blank email to internals+get-127210@lists.php.net to get a copy of this message
Le dim. 27 avr. 2025, 22:32, Tim Düsterhus <tim@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 >

« previous php.internals (#127210) next »