Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127491 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 lists.php.net (Postfix) with ESMTPS id A5D7E1A00BC for ; Wed, 28 May 2025 04:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748407970; bh=1jbynAgq0tTr6Eb4yW/Vc0xQdVdqLZ8eqVrK46jufOY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Kofa5Q0ZFQw2tK1oI5j/u96MImAwW56c+U8kvnMDm64bqZJv/bsUNPitDuQ6ajWU8 AZ6FE01baYGM/j5qQ2fmLJ2l5NhWc6lPViNCizt97KUwvsMd9WDzNRPNKb0o19wj9x KVPYUXPTj0aqt81POB3QeJVTR7QxL/+qryhb/21R7889+X/+Y3YwN2HXSoFyOYvXoQ wgv7x+oIb8T5oLQCmnDsjlpL3WCwirYFcNWdxR2+C9gb71epQuPoOah+/ZZ3ZuHZQf VrB+UoqyfO9ne7uNGOahmAxfabyJKspnbOxgaH4XzyjGXuTs5OA7bMmO/CmA1N8FE1 Exxv0tvJIpOrA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BA48E1801D9 for ; Wed, 28 May 2025 04:52:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) (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, 28 May 2025 04:52:49 +0000 (UTC) Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-e7dc4e44b47so1332003276.3 for ; Tue, 27 May 2025 21:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1748408095; x=1749012895; 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=1jbynAgq0tTr6Eb4yW/Vc0xQdVdqLZ8eqVrK46jufOY=; b=N+zxARihQTRD7EGUazmd7k5yTH3y7/1ozVTJaIrthzDK39IaPSWUOVE4xIkDO/V1rY gB6vTcjsoY5oLYb1wrXZd+Jgva+qVRllqaf0I91MtEJT93b3eQGo6Yk1ffeED45fId4f J/pt0gehUzapKmC6w7iyQnOUk8jJLCLKCyiSLRZGUn/xj8T9TidzMQcF/kk2Teki9s9h AUb12lc1sOp0QTqr4Ielsp5fr494QqHipbeHd21mZr95AqFMeS+Ma/QYraMGM5hd+mzt lKt6Dn0U5XhWoYRD1h8dd1LMldwlWey0kpLMfsh3ICJ41SKbLWGt5o+Kjpk9qTHfDWaV ctNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748408095; x=1749012895; 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=1jbynAgq0tTr6Eb4yW/Vc0xQdVdqLZ8eqVrK46jufOY=; b=H4wrAAGYwf8RKt8bqXPZTedfi17lOhoV8sZBg+EII0xnhYKQMnKpCTf9DlUzlgmo0V Gajg043GW4MdB5dxt5z2XZOBWc0lpcfh8NqQuuZMLtX3GukUc9wRC78wXics4bi/zSVG LKhTswr+oimclmKBkAce6WoCh8UpDTsKgxKV4wwnrUrLMqyFVS6J2o39fqV+iSJWZSbh HiF/VkJH6Y08Fj+Zpd8GUa9jeUVY5nyl46AEjTZrb0/GRxse/qZ7EVMdBWivXWcxoQFh SkMf6UaSFE1NPW84XPG9FsA8GZGBIKYvcQiIiXsld2H+5e+ziwhQ2VLsbCkYl+NWXrg3 0T3w== X-Gm-Message-State: AOJu0YwzWEqUib211XoI8biu+t4jRgxMc1w5DsPMvpJV6NOeRZiYtThy KgtLjfGQQYErFYmvP4WNe22/uR3QZdxJRJxmxAqOeAAxoVakZbliHetz3U3vzqkJZhW0jqhJ3+K KCE0SgaDT8X24T4qCPRnvwLwBicbCkmiPBlEI X-Gm-Gg: ASbGncvwbOFHLvum/1M3PnKRCkqG9NSfGFk4XDmwOciL2kyCLGcnC8KHcN3xNr8bHp9 ZjKWkyzOei6cWeRcKSSwwsE+KuQ9JxdSd53qw8vu4SF2eMgrIA3JbwJhKPvjo8N0kmdMZvc79dn 0krCdyMbqSTwEvyfU7WKCCnF0VGhgBRWKRJelw23QqJZWzvvOUbkjFxIhP5/ucqSCS X-Google-Smtp-Source: AGHT+IEH6wA4pRfCKXeiM7quDPs6nbYF2jxVQLVGsj3dtg/bRJC8HaIpQA9g/w/v3nHVtKK7vkHhFoAlISCq6+MavRs= X-Received: by 2002:a05:6902:18d3:b0:e7d:5a5a:1063 with SMTP id 3f1490d57ef6-e7d9175b038mr18621406276.10.1748408095294; Tue, 27 May 2025 21:54:55 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <329A033B-585E-45CD-8171-D0CE8334A8B2@php.net> In-Reply-To: <329A033B-585E-45CD-8171-D0CE8334A8B2@php.net> Date: Tue, 27 May 2025 21:54:22 -0700 X-Gm-Features: AX0GCFvrZrJy5Yct29bV8p_ZmRpY_tg768C_wwwHBgnJM7bR3g9zOte9QcaOhDE Message-ID: Subject: Re: [PHP-DEV] #[Deprecated] Attribute To: Ben Ramsey Cc: PHP Internals Content-Type: multipart/alternative; boundary="00000000000071475c06362afb28" From: daniel.e.scherzer@gmail.com (Daniel Scherzer) --00000000000071475c06362afb28 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 27, 2025 at 9:41=E2=80=AFPM Ben Ramsey wrote: > > Last night, I identified a need for `#[Deprecated]` on a userland class i= n > one of my libraries, but I had to settle on `@deprecated` for the widest > range of compatibility. > > Has there been anymore thought on putting together an implementation for > this? I=E2=80=99m happy to draft an RFC if someone is able to help with t= he > implementation. I don=E2=80=99t understand the complexities around the > implementation, but is this something that could make it into 8.5, provid= ed > an RFC vote passes? > > Cheers, > Ben > > I'd be willing to work on the implementation, but what I'm wondering is what exactly it would mean to deprecate a class. Without a clear idea of the goal, I didn't include this in https://news-web.php.net/php.internals/127305 even though I had considered it. Would a deprecated class * Emit warnings when constructed? Just deprecate the constructor, https://3v4l.org/DNrqm * Emit warnings when used as a type? But we allow types to include classes that don't exist (https://3v4l.org/pdkbv) so needing to look up the types that are declared to emit warnings (rather than just when used to verify that the type is respected) would presumably have a performance impact. * Emit warnings when extended? I suggested that in my email a few weeks ago, and when I have time I was going to look into that - I was thinking something like `#[\WillBeFinal]` that would work for classes, methods, properties, and constants, and would emit warnings just like `#[\Deprecated]` but not when a method is called or a constant is used, just when things are overridden What were you thinking in terms of desired semantics? --Daniel --00000000000071475c06362afb28 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, May 27, 2025 at 9:41=E2=80=AFPM B= en Ramsey <ramsey@php.net> wrot= e:

Last night, I identified a need for `#[Deprecated]` on a userland class in = one of my libraries, but I had to settle on `@deprecated` for the widest ra= nge of compatibility.

Has there been anymore thought on putting together an implementation for th= is? I=E2=80=99m happy to draft an RFC if someone is able to help with the i= mplementation. I don=E2=80=99t understand the complexities around the imple= mentation, but is this something that could make it into 8.5, provided an R= FC vote passes?

Cheers,
Ben



I'd be willing to w= ork on the implementation, but what I'm wondering is what exactly it wo= uld mean to deprecate a class. Without a clear idea of the goal, I didn'= ;t include this in=C2=A0https://news-web.php.net/php.internals/127305 even though I had = considered it. Would a deprecated class

* Emit war= nings when constructed? Just deprecate the constructor,=C2=A0https://3v4l.org/DNrqm
* Emit warnings w= hen used as a type? But we allow types to include classes that don't ex= ist (https://3v4l.org/pdkbv) so need= ing to look up the types that are declared to emit warnings (rather than ju= st when used to verify that the type is respected) would presumably have a = performance impact.
* Emit warnings when extended? I suggested th= at in my email a few weeks ago, and when I have time I was going to look in= to that - I was thinking something like `#[\WillBeFinal]` that would work f= or classes, methods, properties, and constants, and would emit warnings jus= t like `#[\Deprecated]` but not when a method is called or a constant is us= ed, just when things are overridden

What were you= =C2=A0thinking in terms of desired semantics?

=C2= =A0--Daniel=C2=A0
--00000000000071475c06362afb28--