Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126182 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: by qa.php.net (Postfix, from userid 65534) id CBC591A00C5; Fri, 27 Dec 2024 13:49:30 +0000 (UTC) To: internals@lists.php.net Date: Fri, 27 Dec 2024 14:48:43 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API Content-Language: fr Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 94.225.114.231 Message-ID: <20241227134930.CBC591A00C5@qa.php.net> From: nyamsprod@gmail.com (ignace nyamagana butera) Hi Maté, I finally got the time to review the proposed API and I did some experiments using a PHP userland polyfill for RFC3986Uri to test the water and to see if I did understood everything. First thing first, the API is really well thought and at least for me and my League/Uri package it is really easy to go around and use it if needed. Having said that I had some questions during implementation. Specifically for RFC3986Uri I see that the only difference between the `parse` named constructor and the constructor is that the former will return `null` instead of throwing an exception. But it is not clear if both methods can work with partial URI. What is the expected result of new Rfc3986Uri('?query#fragment'); will the class throw an exception because the missing base URI or will the parsing still occur and return a new instance of the URI ? Whatever the answer I think it should be clearly stated in the RFC. Because from the look of it One may think that partial parsing which is use a lot is not longer supported and possible and that the URI should always be absolute. If partial parsing is in fact no longer supported maybe a distinct method should be added to support for that scenario. AFAIK, the WHATWGUri does not support partial URI and always required an absolute URI. So maybe adding a distinct named constructor specifically for the RFC3986 would make understanding the code easier and reduce suprises on usage ? I also think that the RFC should emphasized that the RFC3986 URI is only **parsing** the URI and not validating the URI like the WHATWGUri counterpart. the following URI will pass without issue new Rfc3986('https:example.com'); this is a valid RFC3986 URI but it is clearly not a valid http URL.