Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126484 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 79A2C1A00BC for ; Mon, 24 Feb 2025 09:15:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740388346; bh=mFFhYybzmxfRLV4xTBt0vLqwx+eP3McksAPjhTwidhs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=X4PYxK7ZKqZJvXq8VbyCTKc9qOZqxuKJcxpGxw8nGkqblx44LmKai8jfbxXKXiaX9 NCE66tL7/y8FemdgH2nqxVvLmmHOUo8OJHaMFNQL+muYrhSqqotCSUe2mOmvhHAiw8 c6eRr89cjqOLcR/gWg+qdUQTehPiZHtSPV0mnLoTWOfHKhGZ/cQCMK1Q6limjRZ5IJ ny/x/1D7zcET2Dl8f2Kus0z3fliDAQVXvuPxEzaXW9/Q+guZvY8HAtGLO1g+dfy+NY 4xZ2MUXz8SpITElBlr/2b4ijzncizP+hpUUSL8ddVGDcH8XQnWBBcnvrN3NE30DZZO LXuf90ts/KDoA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B7411801C7 for ; Mon, 24 Feb 2025 09:12:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 24 Feb 2025 09:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1740388501; bh=H7sluXJB4ku1T8xFMXFA/FisVBcuRNQvjtvh6bBeJEQ=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=Ch7Z9qx0eHi/iCuiKgdBUMDIg1JgGYomU6zLTwLf6WnB9UZaCroLa0fENOEknXrSn YuX4qpDR3spheNGgqyBajqN8mntPcxfJTlYigtGUxePmq3mEgtQIcB95OAbiyBzV7+ 5/7wLxtXXUWkkL0HfHmisCIme1TY3vf/jSue2BN3YQX+H5qJxMqZTi5Rj+pz9N7oWA 4UymBRo78pdXNE2XHWJ1Hr1mxVTob4g1654qUpZsSqlYMf7yiuYyQJI5yyjZNxpwi8 Puy4o0Znh2fFAG1V4fa7xqGdvEcAMkjMMgrScUddsblcYd76t7rkqyqy+GeOOSJD0B AzNYYQ8FwTf9w== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Mon, 24 Feb 2025 10:15:01 +0100 To: "Gina P. Banyard" Cc: =?UTF-8?Q?M=C3=A1t=C3=A9_Kocsis?= , PHP Internals List Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API In-Reply-To: References: Message-ID: <17bdbfa35c920a86a19690e356e05f99@bastelstu.be> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-02-23 18:30, schrieb Gina P. Banyard: > 2. > I don't really understand how the UninitializedUriException exception > can be thrown? > Is it somehow possible to create an instance of a URI without > initializing it? It's mentioned in the RFC (it was not yet, when I read through the RFC): > This can happen for example when the object is instantiated via > ReflectionClass::newInstanceWithoutConstructor()). Incidentally this is *also* something that would be fixed by making the classes `final`, since it's illegal to bypass the constructor for final internal classes: newInstanceWithoutConstructor(); results in: Fatal error: Uncaught ReflectionException: Class Random\Engine\Mt19937 is an internal class marked as final that cannot be instantiated without invoking its constructor > This seems unwise in general. I agree. This exception is not really actionable by the user and more of a “should never happen” case. It should be prevented from appearing. The same is true for `UriOperationException`. The RFC says that it can happen for memory issues. Can this actually happen? My understanding is that the engine bails out when an allocation fails. In any case if a more graceful handling is desired it should be some generic `OutOfMemoryError` rather than an extension-specific exception. With regard to unserialization, let me refer to: https://externals.io/message/118311. ext/random uses `\Exception` and I suggest ext/uri to do the same. This should also be handled in a consistent way across extensions, e.g. by reproposing https://wiki.php.net/rfc/improve_unserialize_error_handling. And with “Theoretically, URI component reading may also trigger this exception” being a theoretical issue only, the `UriOperationException` is not actually necessary at all. > 3. > I'm not really convinced by using the constructor to be able to create > a URI object. > I think it would be better for it to be private/throwing and have two > static constructor `parse` and `tryParse`, > mimicking the API that exists for creating an instance of a backed enum > from a scalar. enums are little different in that they are a singleton. The Dom\HTMLDocument class with only named constructors might be a better comparison. But I don't have a strong opinion on constructor vs named constructor here. Best regards Tim Düsterhus