Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126492 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 78AAD1A00BC for ; Mon, 24 Feb 2025 13:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740405312; bh=Eo7K550pjKx+6I3XRkNoADYGOVHUFRGPdZEws1ou+R4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HQZnfe1IAs8QGNxAB4U/zj72AlZ7S2SFC0aCdHIIh/TReapHe3rcje98a6r9hil5z jBonm+KRcwL8mhbFFtDse+6yyc6hpeDy/vEAMrn/AgpJ1P1ah6jlJOJ7bu5Sz3I0aq 9Hjpla9BYKn27v0ZGWB434xNwKHCMd6QMBYOOQd3+SLvQVLY9hBBGN4JJWHHg9z/KV NIt4SslsSCvCGnOvC5utoitBxnPaaLYbaXF6pbhFqxy5sv6iC1Znhz6XhmkQ7ZwCrT bmUPAUO8pjz07tWms1jRTDjasnJ3Dnr7fNHdz1ZXPDAuttjbKyD1DwFuCkaK1iFxz6 X45nnHS9gccfA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 78263180066 for ; Mon, 24 Feb 2025 13:55:11 +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=0.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,URIBL_SBL_A autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 13:55:08 +0000 (UTC) Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-2fc1f410186so9304228a91.0 for ; Mon, 24 Feb 2025 05:57:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740405466; x=1741010266; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Eo7K550pjKx+6I3XRkNoADYGOVHUFRGPdZEws1ou+R4=; b=WkfE242HPUMEt3bmTPe3W5G0cEQb3k7Q4jYPOxbszbbfSy05KERwMSqNdPFcLglBl6 xaXFk49RtnwyRmCyPnVkp/7aXex3vXQSFAEr9gIY35OIxkzQE3tNKSxiW9BeY2UntoH2 1zjxUX5qnZ1bVAlynW1LLJ/8RU1Jf1gXeYcgcVgdZvrpIs0z6Rgj6zQxNCzAJr58HgqQ NMujF+NUszownW/qhA63QdwFZrlDIDBc0+eieFELoKsP5MkTBD5WfS4Qz2b4LKiSOnOq QDi1XbSltFXLJVcqQB4F5D/R56N69z6EdBRqYf2fPm7b8p6sPpuUvsNzAusgy+fsPtoY sB7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740405466; x=1741010266; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Eo7K550pjKx+6I3XRkNoADYGOVHUFRGPdZEws1ou+R4=; b=Qe0/AXHlJSKogI7TG2/ajwMztsceScafopjdDv9m65zKYLxHIhKIx3kv2rj0MHUVat zHyb8rZ94z2192IDLdat7RSuSpJIpV896StPYwHbNt5cqNFuUDgHjeRIdvU5nbvYTWVh eLpU9R2OnE548uZCAsubsXaTWxzt3DOamwXUHCCpFaMd/aB/Fg/R/eM/2JyXKJMPFmP3 ZS5BnYmeubHrin5oXyeqi4lxEUsn4tx9flTyop1ns+Q/KVmNiVG5ZR6exZi7BPmV53jm 53fpH7zreP1zpKaGgPxRr9gTri5CeXKLPgZY0NBNg2Ba8OPVfWxQ3nORd1g4ufSEkJcn JN7Q== X-Forwarded-Encrypted: i=1; AJvYcCUCYejBN3mQnmMAeIpZwf4fUlVCj+lO2c7WdZpMjDVzHU/ywtOvIScBCPFk5aQmH9GH78cHemKblA4=@lists.php.net X-Gm-Message-State: AOJu0YxdlEpL5zSL/xZkpxSZKf26ppfjuXkhmBlUlv9Kc/lIfe2XzG0v dFs5HmmYehS/H6RQopHH3I6zdpjnjRqQIBcJsSejq3rJlb+mS6GQi1MZaEuy824OJl7ftQcheEV iaeFJEOj/sFg5xil6jWZUkJZXBN0= X-Gm-Gg: ASbGncvs6YoLdgFtHJSYXKTiGrw3xeeiwA+g1vVm2BiYwhKqiusP6NlM3vuodEKXorX Pp2NV7m0LhnP+/0zD+gB9NhX3lcyIvTy/35VA5AgBHyvj0RZblDGnQVmCogplUB3GWPIqwNtK34 weQSBicYZ7 X-Google-Smtp-Source: AGHT+IFDfWE+9xhkYTjoeAzo87UyRkxdYDuO6Kuy0sxjyn9hW2iB4dh2SjnGKT/UuBnSDuzIityD3DHnqHaaeBma7/o= X-Received: by 2002:a17:90b:52cf:b0:2fa:6793:e860 with SMTP id 98e67ed59e1d1-2fccbfbc738mr31329470a91.0.1740405465490; Mon, 24 Feb 2025 05:57:45 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1BCB4144-231D-45EA-A914-98EE8F0F503A@automattic.com> <8E614C9C-BA85-45D8-9A4E-A30D69981C5D@automattic.com> <9bf11a89-39d9-457b-b0ea-789fd07d7370@gmail.com> <804ddb57fee36c23839c5b5a50ddd51f@bastelstu.be> In-Reply-To: Date: Mon, 24 Feb 2025 14:57:32 +0100 X-Gm-Features: AWEUYZnghyAHowxBv-BItzapfMQmdDiSD_ekj-spsXnWNC76xvbhxHaFkNaXPWE Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] Add WHATWG compliant URL parsing API To: Nicolas Grekas Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000892c8b062ee3b9fc" From: ocramius@gmail.com (Marco Pivetta) --000000000000892c8b062ee3b9fc Content-Type: text/plain; charset="UTF-8" On Mon, 24 Feb 2025 at 14:45, Nicolas Grekas wrote: > > > Am 2025-02-24 12:08, schrieb Nicolas Grekas: >> > The situation I'm telling about is when one will accept an argument >> > described as >> > function (\Uri\WhatWg\Url $url) >> > >> > If the Url class is final, this signature means only one possible >> > implementation can ever be passed: the native one. Composition cannot >> > be >> > achieve because there's no type to compose. >> >> Yes, that's the point: The behavior and the type are intimately tied >> together. The Uri/Url classes are representing values, not services. You >> wouldn't extend an int either. For DateTimeImmutable inheritance being >> legal causes a ton of needless bugs (especially around serialization >> behavior). >> > > DatetimeImmutable is a good example of community-proven usefulness for > inheritance: > the carbon package has a huge success because it does add a ton of nice > helpers (that are better maintained in userland) while still providing > compatibility with functions that accept the native type. > > The fact that the native implementation had bugs when inheritance was used > doesn't mean inheritance is a problem. It's just bugs that need to be > fixed. Conceptually nothing makes those bugs inevitable. > > Closing the class would have hindered community-innovation. The same > applies here. > > TBH, data-point from someone that spends time removing Carbon usages here :-P The `DateTimeImmutable` type should've been `final` from the start: it is trivial to declare a userland interface, and then use the `DateTimeImmutable` type as an implementation detail of a userland-provided interface. PSR-7, for example, will benefit greatly from this new RFC, without ever having to expose the underlying value type to userland. Inheritance is a tool to be used when there is LSP-compliant divergence from the original type, and here, the PHP RFC aims at modeling something that doesn't have alternative implementations: it's closed for modification, and that's good. Marco Pivetta https://mastodon.social/@ocramius https://ocramius.github.io/ --000000000000892c8b062ee3b9fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Mon, 24 Feb 2025 at 14:45, Nicolas Grek= as <nicolas.grekas+php= @gmail.com> wrote:


Am 2025-02-24 = 12:08, schrieb Nicolas Grekas:
> The situation I'm telling about is when one will accept an argumen= t
> described as
> function (\Uri\WhatWg\Url $url)
>
> If the Url class is final, this signature means only one possible
> implementation can ever be passed: the native one. Composition cannot =
> be
> achieve because there's no type to compose.

Yes, that's the point: The behavior and the type are intimately tied together. The Uri/Url classes are representing values, not services. You wouldn't extend an int either. For DateTimeImmutable inheritance being =
legal causes a ton of needless bugs (especially around serialization
behavior).

DatetimeImmutable is a good = example of community-proven usefulness=C2=A0for inheritance:
the = carbon package has a huge success because it does add a ton of nice helpers= (that are better maintained in userland) while still providing compatibili= ty with functions that accept the native type.

The= fact that the native implementation had bugs when inheritance was used doe= sn't mean inheritance is a problem. It's just bugs that need to be = fixed. Conceptually nothing makes those bugs inevitable.=C2=A0
Closing the class would have hindered community-innovation. Th= e same applies here.


= TBH, data-point from someone that spends time removing Carbon usages here := -P

The `DateTimeImmutable` type should've been= `final` from the start: it is trivial to declare a userland interface, and= then use the `DateTimeImmutable` type as an implementation detail of a use= rland-provided interface.

PSR-7, for example, will= benefit greatly from this new RFC, without ever having to expose the under= lying value type to userland.

Inheritance is a too= l to be used when there is LSP-compliant divergence from the original type,= and here, the PHP RFC aims at modeling something that doesn't have alt= ernative implementations: it's closed for modification, and that's = good.

--000000000000892c8b062ee3b9fc--