Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123197 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 32AB71A009C for ; Wed, 24 Apr 2024 09:02:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1713949374; bh=c4rYAvkcSf2aWKssRaQw1QaVIY9PQBp1FkBu1to9l7g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=S8Q7RMmYE3CbcEPBYMnjbcXfR77E/kQaYgMnQhj1PO7ihROGHwalVaPYy9aIMhDrg BJBZX545UW6eacRKhWIt0lZ4XWVfre5LCvJ6vk4q+TuU8J3+aTyUTyY96J5GP6d4k5 DvzTgwB5gKyC0E/jOkihrV8H+QDf98KqHwfCy81rn6nFVeajYaknP8hweG06GG2b5G k4LyHY9+JP5amkGGLynT8haYgGEiujeeOn6RA0u3PSkEwB8kXNzSWAaS5o1kwVEnDL hF/5Rc1MiUg19TN+2W2DFuvD2pgtX5ByH9DQJNnZHLMtNO5aAu/daO02Gm2LbdIh16 9y7PnIrYnCODQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A704A1804DB for ; Wed, 24 Apr 2024 09:02:52 +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.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) (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 ; Wed, 24 Apr 2024 09:02:52 +0000 (UTC) Received: by mail-vs1-f53.google.com with SMTP id ada2fe7eead31-479e12bde9fso2382235137.2 for ; Wed, 24 Apr 2024 02:02:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20230601.gappssmtp.com; s=20230601; t=1713949331; x=1714554131; 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=fKdzugDcbi+WGLwAFDTOLKuUxzjG8/3BjFkwBOwVrRE=; b=si9p7glgPsUQsIQWh7KVTtgQXXOleXWhtX3/dCpb5OqvhqE6BVo1tg4SMGOjXrxe3p LzhI/5R8ZhH+eNJY7hCXtEek4/aKHFKTeIhiZHUGZ5RX6OnvL8d3jT/23No/nYuyMoG0 PbMfimUGsICDMOgr6sRL/nvfAvh8zoaJEwF3jO/feYiF23o0VNGOYGDfKncz63sIvfRF pbixY7PRfwcMWax1wxkKr0U564gvmfIboCbz/CXsu4rxHVo3KggT1ujvHyy8Jz0rdb1h UAVgIQ9SH+BwsFzeDR+YbqdSe4TexobUbdl0RHb0KMxIe0dOvCM9N1d/0FkEFVpQcVbL w9bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713949331; x=1714554131; 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=fKdzugDcbi+WGLwAFDTOLKuUxzjG8/3BjFkwBOwVrRE=; b=dTOs0HHWK1PtWICnZOmKRXC6gbjlyNEZ1Ofz0qyGpIyEzEGFT9z/jPHmS+zs1eFshc n56jzeicGVEkPVniZ1LqKNa/dLKhYEzxltTY14pRGQrmbsnOUZdHgvtnHVdQGuKDJq4E uCuKdO9RyoVHJbBG8BciAG6MceuV9Ue/d+lVUQ+ALIk9sMsyvGg8dBwy3rEQoetmeizR aV+6D5j7w1F2FLyfo0ERAqpC5em1pqnWW57LtUyWnCQrlWs1pl0sBTDWLnOBG+GcXKeK qWZYJYJnYMyoskZ+vpaQxf4bdQhzde6f42oFwstEoqV85moGdJlL3JrTI2yXNf7+pnAk vp5w== X-Gm-Message-State: AOJu0YxnHY2cQHdRUvPouoQ7GipC7ZcXNIr/bkWiuYsS1VwzDjkcrqKW Yv1Ps+dV4U1T3cQra7cKfaCqiZNfYAdGqNnzJJ0siS8LxgP7Oc4RNIUW6O2gYUpYTakmuyhxMvn 3bKKGRLVl+tPFirDqWnnjHFj/YRnGW1tpvqR+cw== X-Google-Smtp-Source: AGHT+IGyHrl842iwq43oSLEes0wIX9Slse2UW63yBoyb+F4EXrUpHY9NV2e8cstp95SDgcE2Z985eZvmdeJL+mJSNiw= X-Received: by 2002:a67:e99a:0:b0:47a:42d8:f017 with SMTP id b26-20020a67e99a000000b0047a42d8f017mr1797078vso.30.1713949330916; Wed, 24 Apr 2024 02:02:10 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 24 Apr 2024 11:01:58 +0200 Message-ID: Subject: Re: [PHP-DEV] [RFC] [Discussion] #[\Deprecated] attribute again v1.3 To: Levi Morrison Cc: PHP Internals , "tim@tideways-gmbh.com" Content-Type: multipart/alternative; boundary="0000000000000864db0616d3ed9f" From: kontakt@beberlei.de (=?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?=) --0000000000000864db0616d3ed9f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 23, 2024 at 7:27=E2=80=AFPM Levi Morrison wrote: > On Tue, Apr 23, 2024 at 7:30=E2=80=AFAM Benjamin Au=C3=9Fenhofer > wrote: > > > > Hi internals, > > > > My PR for #[\Deprecated] attribute was in hibernation for a long while > now and after some off-list discussion a few weeks ago I have decided to > revisit it and asked Tim to help me out with the work. > > > > Tim has cleaned up the PR quite a bit and also worked in additional > features such as #[Deprecated] support in stub generation. > > > > While there are still some small todos, at this point we want to restar= t > the discussion about the RFC for inclusion in 8.4: > > > > RFC: https://wiki.php.net/rfc/deprecated_attribute > > PR: https://github.com/php/php-src/pull/11293 > > Old discussion: https://externals.io/message/112554#112554 > > > > Let me know about your questions and feedback. > > > > greetings > > Benjamin > > I skimmed through the previous discussion and didn't see anything > about adding a `since` property. This is occasionally useful, at least > in my limited usage of it in Rust. The names below are modelled after > the names in [Rust's deprecated attribute][1], but "note" is the same > as the proposed "message": > > ```php > #[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)] > class Deprecated > { > public function __construct( > public readonly ?string $note =3D null, > public readonly ?string $since =3D null > ) { > } > } > > #[Deprecated(since: "1.3", note: "this is not good, use good_pls_use")] > function bad_dont_use() {} > > #[Deprecated("this wasn't meant to be public, use good_pls_use instead") > function oops_dont_use() {} > > function good_pls_use() {} > ``` > > In Rust, you get a message for each of ["since" and "note"][2]. In > PHP, this might look something like: > > > Deprecated: Function bad_dont_use() is deprecated since 1.3, > > this wasn't meant to be public, use good_pls_use instead in %s > > on line %d > This request is similar to Roman's question about a replacement parameter elsewhere. We are unsure about these, because from an engine POV they do not add value, and from a user messaging perspective they could be put into the message with #[\Deprecated("since 1.3, this is not good, use good_pls_use")]. The only reason this might make sense is to allow third party tooling to work on this, but there are no conventions ala php-doc here in place already. If tools need more infos, they could just introduce their own attributes. example: #[\Deprecated, Since("1.3"), Replacement("good_pls_use()")]. It feels arbitrary if we add parameters that the engine does not use and where no tooling conventions exist on how they are being used, so we left them out for now. > [1]: > https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-depre= cated-attribute > [2]: > https://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md#in= tended-use > --0000000000000864db0616d3ed9f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Tue, Apr 23, 2024 at 7:27=E2=80=AF= PM Levi Morrison <levi.mo= rrison@datadoghq.com> wrote:
On Tue, Apr 2= 3, 2024 at 7:30=E2=80=AFAM Benjamin Au=C3=9Fenhofer <kontakt@beberlei.de> wrote: >
> Hi internals,
>
> My PR for #[\Deprecated] attribute was in hibernation for a long while= now and after some off-list discussion a few weeks ago I have decided to r= evisit it and asked Tim to help me out with the work.
>
> Tim has cleaned up the PR quite a bit and also worked in additional fe= atures such as #[Deprecated] support in stub generation.
>
> While there are still some small todos, at this point we want to resta= rt the discussion about the RFC for inclusion in 8.4:
>
> RFC: https://wiki.php.net/rfc/deprecated_attribute=
> PR: https://github.com/php/php-src/pull/11293
> Old discussion: https://externals.io/message/112554#1= 12554
>
> Let me know about your questions and feedback.
>
> greetings
> Benjamin

I skimmed through the previous discussion and didn't see anything
about adding a `since` property. This is occasionally useful, at least
in my limited usage of it in Rust. The names below are modelled after
the names in [Rust's deprecated attribute][1], but "note" is = the same
as the proposed "message":

```php
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_FUNCTION)]
class Deprecated
{
=C2=A0 =C2=A0 public function __construct(
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public readonly ?string $note =3D null,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 public readonly ?string $since =3D null
=C2=A0 =C2=A0 ) {
=C2=A0 =C2=A0 }
}

#[Deprecated(since: "1.3", note: "this is not good, use good= _pls_use")]
function bad_dont_use() {}

#[Deprecated("this wasn't meant to be public, use good_pls_use ins= tead")
function oops_dont_use() {}

function good_pls_use() {}
```

In Rust, you get a message for each of ["since" and "note&qu= ot;][2]. In
PHP, this might look something like:

> Deprecated: Function bad_dont_use() is deprecated since 1.3,
> this wasn't meant to be public, use good_pls_use instead in %s
> on line %d

This request is similar= to Roman's question about a replacement parameter elsewhere. We are un= sure about these, because from an engine POV they do not add value, and fro= m a user messaging perspective they could be put into the message with #[\D= eprecated("since 1.3, this is not good, use good_pls_use")].=C2= =A0

The only reason this might make sense is to al= low third party tooling to work on this, but there are no conventions ala p= hp-doc here in place already. If tools need more infos, they could just int= roduce their own attributes. example:

#[\Deprecate= d, Since("1.3"), Replacement("good_pls_use()")].
<= div>
It feels arbitrary if we add parameters that the engine = does not use and where no tooling conventions exist on how they are being u= sed, so we left them out for now.


=C2=A0 [1]: = https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-depreca= ted-attribute
=C2=A0 [2]: https= ://github.com/rust-lang/rfcs/blob/master/text/1270-deprecation.md#intended-= use
--0000000000000864db0616d3ed9f--