Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127160 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 1FB7D1A00BC for ; Tue, 22 Apr 2025 08:44:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1745311314; bh=fz5f6nXvQ3kd5dSvfKmFNQmFF6HrB7+5JuSr3NVNPGk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=H/5+YDSTXKe0zWtsJmlWbuqUUQamGQgmXuOTzRtxceh041lyI23ZEPNkveSbu3o96 9wo9dLK+/FNHrT0Xtq9aOqVGutPlsCgSi0EHjmzXJl1SVtG4M10qTPk0XwYHphz1gS kqRlrylNF3gn20GCSRMyWfU0Uz4lWB/uxwpnjAyr/sLJ7l+8GWNDPrUVbsoVby0ENX VgWMjlOh4Iddmq74lcNBl00xHsQGTKp2h7Wsd5XkTY/N/gTPxWHkPdK2COKnvqszTl 5XOOS9VoxtfBo0MUA9sB1y7tL1/QiuTZCm5GyPV2iO9llwdeNjXcbiLLcEvys7D7gF O3kWR81DJv+gg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3B97018006B for ; Tue, 22 Apr 2025 08:41:53 +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.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (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 ; Tue, 22 Apr 2025 08:41:40 +0000 (UTC) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-30572effb26so4376664a91.0 for ; Tue, 22 Apr 2025 01:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1745311438; x=1745916238; 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=fz5f6nXvQ3kd5dSvfKmFNQmFF6HrB7+5JuSr3NVNPGk=; b=HcXUIBG0+RVowMx3HOQ8q+hod+/eh9CW0/OLTFk9t/cI0oCf+OBnU01Z78Ex2MOw+D kiP3vWt2gq3dsYbwlnHLhaOiGF9Kqtw0C7xZFq7Sr2KAnfEUAOtjvH2bJexqLHDjFpG9 W/uMiGhWHWTkaG3kE5si8Iwfnd6EpsnFMgqnGG7k98XMwXs0VxXJ0BdA5rY9D5y5pv9p SspC6L9XALG5/bum4hyuwWjnkaqQ2bgNxlditq45T+hR0IdQjs7AFs7AqbH/7VkW0E02 Xqd3Ov7NXCU+lc+tCU7yRA+eaTOzvRgiQJiKEaSI4f/XNDUX+WavTU7Gru+qzkZcT5Y4 N/yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745311438; x=1745916238; 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=fz5f6nXvQ3kd5dSvfKmFNQmFF6HrB7+5JuSr3NVNPGk=; b=PTwYg3VLzfQcQd/2g0TsUYwbbkZ3Q2nCWdzk3i1oQi7BKYLL2L/3T9zc8KobvjhP79 F2vwdD+T3q6jqU6X1rYoyjTba4Qv6IXs2oLEXUChF01lSmNxn6vVgLwqpEmN0UgT4PfV km72ohVkQB8jVqzP6vlUVq6CEbqhbDOUUavemY7V0SXILbdy7dg0Ui4Fmg87cQvFGWQT QgLGPe87n+74SXjehle1GuvxxX+Ti1Bdqj9djthq48MuqdpAdyR261kWIkLr7FBdCIfl 5bIo4GpdCMlDYQJ1sTymu0OjXLaXYyUoGzCz5QHfmXS6BLuXUmxnCqT8gvkQZdnbh4A2 +Ciw== X-Gm-Message-State: AOJu0Yzytg+qF4Pt7joPDt2+2o6U2Urs+bMkD4gLltN4Eud5ySOb2MK+ I+992H6e0F8dM+9e3DilBt8IBQmeansFP85ua3Wz0QkUnCRu7lHDnKYgE4uUXWh9Y/mr7vk9Ru8 jU7trrxtPUMNERbcdKTPhtVOWDRo= X-Gm-Gg: ASbGncs6p2Ow9G4FsyRchLd3X0AWQ2Y8TzGnNKOLARgnCKPvaJU0aRJ12puhigZ74Ph 9R1dZMeDFov6D1UTMnEL/+Gw8dSm3FKGGBl+QK+byd4q+0nMM+JoQ5MafUdZDNNOaW1JLpwJqww dR1ePUNfRYbsRusH60tfGgpzI= X-Google-Smtp-Source: AGHT+IF++v1wv32VWoP7veEAE4KgS7NmO4vuEUfTOFzgsNrW4KEYhiJHuHmKjFOZA6N/cJygNFWsQcAuWvnioL+BvbQ= X-Received: by 2002:a17:90b:588c:b0:2fe:9e6c:add9 with SMTP id 98e67ed59e1d1-3087bb631b0mr26528495a91.18.1745311438406; Tue, 22 Apr 2025 01:43:58 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 22 Apr 2025 10:43:46 +0200 X-Gm-Features: ATxdqUHNMB_vw3C27ykgwqX2IOVgeWcQr3E21q6k56maftJ2qI_sXV4-M-M6bbo Message-ID: Subject: Re: [PHP-DEV] [VOTE] Never parameters (v2) To: Daniel Scherzer Cc: php internals Content-Type: multipart/alternative; boundary="0000000000004f0f0e063359fcd7" From: ocramius@gmail.com (Marco Pivetta) --0000000000004f0f0e063359fcd7 Content-Type: text/plain; charset="UTF-8" Hey Daniel, I'm currently planning to vote "no" on this. The reason is that I see this RFC as very narrowly scoped on constructors / named constructors, and only in the case where a concrete class is referenced by a consumer. Constructors/named constructors are effectively not part of an object's signature, but are rather functions attached to a namespace. One could argue that `BackedEnum::from()` and `BackedEnum::tryFrom()` should never have been interfaced anyway: a consumer relies on the concrete class here anyway. At the moment, I don't see how a `never` parameter would be used on an instance method. I also disagree with the "Userland example" section (`CommonMark`) where narrower parameter types would be used on concrete implementations of an interface, hence breaking LSP anyway, if one refers to the parent type in their code. The current `CommonMark` "add a runtime assertion" approach is IMO sufficient, and this RFC doesn't seem to improve the situation, effectively swapping an assertion failure with a `TypeError`. An example involving PHPStan and Psalm (and showing a sound implementation with generic types) would go a long way. Something that shows how to efficiently use `never` on an instance method, and have the entire thing type-check in PHPStan / Psalm would really help: perhaps even the `CommonMark` bit. Marco Pivetta https://mastodon.social/@ocramius https://ocramius.github.io/ On Mon, 21 Apr 2025 at 22:16, Daniel Scherzer wrote: > Hi internals, > > I have opened the vote on https://wiki.php.net/rfc/never-parameters-v2. > The vote will run for 2 weeks (and a few hours), closing on May 5th at the > end of the day (UTC). > > --Daniel > --0000000000004f0f0e063359fcd7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hey Daniel,

I'm currentl= y planning to vote "no" on this.


The reason is that I see this RFC as very narrowly scoped on constr= uctors / named constructors, and only in the case where a concrete class is= referenced by a consumer.
Constructors/named constructors are ef= fectively not part of an object's signature, but are rather functions a= ttached to a namespace.


One could a= rgue that `BackedEnum::from()` and `BackedEnum::tryFrom()` should never hav= e been interfaced anyway: a consumer relies on the concrete class here anyw= ay.


At the moment, I don't see = how a `never` parameter would be used on an instance method.

=

I also disagree with the "Userland example&q= uot; section (`CommonMark`) where narrower parameter types would be used on= concrete implementations of an interface, hence breaking LSP anyway, if on= e refers to the parent type in their code.
The current `CommonMar= k` "add a runtime assertion" approach is IMO sufficient, and this= RFC doesn't seem to improve the situation, effectively swapping an ass= ertion failure with a `TypeError`.
An example involving PHPStan a= nd Psalm (and showing a sound implementation with generic types) would go a= long way.
Something that shows how to efficiently use `never` on= an instance method, and have the entire thing type-check in PHPStan / Psal= m would really help: perhaps even the `CommonMark` bit.

On Mon, 21 Apr 2025 at 22:16, Daniel Scherzer <= daniel.e.scherzer@gmail.com<= /a>> wrote:
<= div dir=3D"ltr">Hi internals,

I have opened the vote on= =C2=A0https://wiki.php.net/rfc/never-parameters-v2. The vote will run f= or 2 weeks (and a few hours), closing on May 5th at the end of the day (UTC= ).

--Daniel
--0000000000004f0f0e063359fcd7--