Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126498 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 F41331A00BC for ; Mon, 24 Feb 2025 16:22:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740414004; bh=WwPoKZJPalhrcCkbJ9zS0hCc8iHdfyyPXcEi784DrHw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IAWreyUXZ9xyTNwv3FGHCTvxm4qQioalD2XEkSQNWEucT8wGNcuA+tiIPOd/zjNGx vsvkCW7cVx6aN4R+RR4H/pdcPR/jh5EAOQY0X4c5e62MGaHd1omATLwnX0+PUGPPoR mhSlVGWSAMMjMiKAz6Z00WSq7kh2MVLQIZxZNQCkqycicYwtjC3VLXrfSwQf10Hm12 Goew2zdkJZbINRRnThYzWtmfmx4WqFNIa++PGNhYbrNAGIhvaYp8jq/tTQserzhESL xdpQIRUa9uo7TXNfbgR13hYtojw4a0vBbuwsuWcaK52aNfNnngvb7gVgKVfdi+j21C IvhZq9aDNgsqA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EFC771801E4 for ; Mon, 24 Feb 2025 16:20:03 +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 16:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1740414160; bh=n8DMSeMjxJ9GfDn+X70VioPLGj1aoJebgOBCo92TWeI=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=RbWHhUXqDj3rcfzedNJrfYHQo5YAwFeA63cMC1cZZO0kKX98IapW0c3EWhIVVFJ9Z nzGZxalW0lSjnXvdvRjEeziTfJA09OwYBbxUZmS/ugvG52vWFj83jxSV241DrUvopZ K0LKNC6QaxW60iu9CqdSqd0iJq8V10/U1oB1YgTDPntLF2sBHz5WTs7ELYlTLiE8Ka eJaHjyF5TmotXO9veeU1kZtJxJoKbl/qa9P+Ljk751MQSr+okofNq8ByuVCUOCaDli hsfICHVg6uxFUt0+xFVITVsi3am1+LtnfAs6erEW+vnKIPR71ftviPDufW1T1v7niD wh4gyB1OwlqDg== 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 17:22:39 +0100 To: Hammed Ajao Cc: "Gina P. Banyard" , Nicolas Grekas , internals@lists.php.net Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API In-Reply-To: References: <1BCB4144-231D-45EA-A914-98EE8F0F503A@automattic.com> <8E614C9C-BA85-45D8-9A4E-A30D69981C5D@automattic.com> <9bf11a89-39d9-457b-b0ea-789fd07d7370@gmail.com> Message-ID: 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-24 15:05, schrieb Hammed Ajao: > What's wrong with declaring all the methods as final eg. > https://github.com/lnear-dev/ada-url/blob/main/ada_url.stub.php It is not possible to construct a subclass in a generic fashion, because you don't know the constructor’s signature and you also don’t know if it added some properties with a certain semantic. That means that the `with*()`ers are unable to return an instance of the subclass, leading to confusing behavior in cases like these: final class HttpUrl extends \Uri\Rfc3986\Uri { public function __construct(string $uri, public readonly bool $allowInsecure) { parent::__construct($uri); if ($this->getScheme() !== 'https') { if ($allowInsecure) { if ($this->getScheme() !== 'http') { throw new ValueError('Scheme must be https or http'); } } else { throw new ValueError('Scheme must be https'); } } } } $httpUrl = (new HttpUrl('https://example.com'))->withPath('/foo'); get_class($httpUrl); // \Uri\Rfc3986\Uri Best regards Tim Düsterhus