Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127501 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 EBD5B1A00BC for ; Wed, 28 May 2025 19:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748458762; bh=Od0vhauPZTDGAS/LXs8cPJzdbEW1s4JXlphCQLBDi3g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=A3vN/zM5h8eSpmZzcYbh8mRwryG9E8yKNGhYAz82hJze+DVW+pdPVVSsTAAduRhuZ TiNt+/wBCjcAtzFjbFBK4RHCe32bfI6UUv3rFQ5F8CQBLozty8EJggOSRJEcibWDHA agTgJdxSKKtq+ZLziZZEigkFIpezlY9ajv7N0TYcStxtufKBw77fg8gnHxP+QPf53M ZJfC+F89KRchWTpdsCpm6T1SZfRfjJKtlA9HbrnYv62ZWhBMFNvc2oZDLcFigexKcq mpDR+Burx61BXsgqhzUFZriKi7Pt/H/K6Aw6cbxJcWnxNUS53dLLm+iOZpy1k8BT53 g2wUvI/24mSdA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 637CF180059 for ; Wed, 28 May 2025 18:59:21 +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=-0.2 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 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-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 18:59:21 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-30f30200b51so1088821fa.3 for ; Wed, 28 May 2025 12:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20230601.gappssmtp.com; s=20230601; t=1748458886; x=1749063686; 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=xNSQ5cfCeu73wZvUGxe/l23MQq5w0TaBjBu5wqDrcYU=; b=cbmmqRl53pTlztdGEug2IDbJTx4/vYGBip8G2de1dENTx8lA7kpIOzfSKd9YWe6mzW FZPPfm4dpwm6a0scfMRKP24xOYC49Dmfq8TpwBfmXPMXK3TGItwpMQWNMgmNqfC8Q0uF +12r9h0t6V45JN7jH/I5SU4qlpIiwfpw0EV/xh6YJSBIpZDaqsl6qruYK8pA8GSWRvf+ 7FB9fie4hQs+/dAtKECo7eBrBQqjfRAtzqOkOkF7Sx5C5SvLawXQmxUJMeGTdP3QWj/g AJLC6k7EIFDorPaR/ysRvvx9cMhoOX7xKFwvv2Mem5enLIY8BlVGSTriujPhu8oWtLMa JcvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748458886; x=1749063686; 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=xNSQ5cfCeu73wZvUGxe/l23MQq5w0TaBjBu5wqDrcYU=; b=SP41LO8gr5GGqMw6D/C+Bvx2D/ObGcybXpiJHYJtcx9snJeQn9pJmnlprUW7NnAsY9 vnYshqDcVtrj7GyyfJJq4X/IRcHb8h9Aep2mcgICSZhi+XiGUxUYTIwYJENKmyxN7V/C jLVXGChhBtKI2nn6mtWlHuF8fw+I08ouumuDoqVKWuifGYbPD5kJPj9y2jJH1WwO3f7w 310J2HHZJJCIk2Nju20Ak1DjQmvGh6RqQ3fyhp8H2hO03nV1tFhfV5rH4gXi+1HzH1Dj yLBrbuafYYD1vYo9Ok0uLZLpeJbT3uE7nCk2mLclB/oKp0BvjxRt2CeaAj0Ry7HOR/Ui XqLw== X-Gm-Message-State: AOJu0YzyEZ39VaXAmOqI6hukP3k73OAD2vlip4jtHlE6kKqy8Ljau4y4 wkx8g2wAUtCRyNym1qI3pkAmaHHnHJoMesGyHASbGXzWW/DXLD+4/9iU+VlfVimbii+pjJGDLzL Y97jRPhMXTaZWX9l2oNOH9hgxjKEL4HJmNUEs29l/ow== X-Gm-Gg: ASbGncuJdGwq1TCriiOhCQoBOZiFe7aryFZYIgODi3Tt3EJfVF4UOz9k2vNnMkJQ7Ki 3b+FKcorcRw4K8Ke1s4fXWmY9VujbMbot68YPHYBftUWAeS2QAg5PkHE8KHXdqUGmMIdnN0L96k S+t4cJo41guO8pQVKCcMtmIOEm0f3hF2/HM2x3wcaQEqBbuasL1vcF95HHsA6H9mWzwg== X-Google-Smtp-Source: AGHT+IHjBkpLzzF5IVGu/cpWrU/cMGoWCdfqJD3J+iunoYqu+xQheIvy7JbbOr10iNaifN/OWICJFB3zN1fSoNVoAzA= X-Received: by 2002:a05:651c:50b:b0:32a:66f7:8a16 with SMTP id 38308e7fff4ca-32a66f78b22mr40343441fa.39.1748458885687; Wed, 28 May 2025 12:01:25 -0700 (PDT) Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Wed, 28 May 2025 12:01:24 -0700 Received: from 1064022179695 named unknown by gmailapi.google.com with HTTPREST; Wed, 28 May 2025 12:01:21 -0700 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 (Mimestream 1.6.3) References: <329A033B-585E-45CD-8171-D0CE8334A8B2@php.net> In-Reply-To: Date: Wed, 28 May 2025 12:01:24 -0700 X-Gm-Features: AX0GCFu8T4X0t1oZn22jyZqkaRlklzOlkZUqujrTW-qnTb38T4B-BVNkHshpv_0 Message-ID: Subject: Re: [PHP-DEV] #[Deprecated] Attribute To: Daniel Scherzer Cc: PHP Internals , Ben Ramsey Content-Type: multipart/alternative; boundary="000000000000c95c5b063636cef7" From: kontakt@beberlei.de (=?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?=) --000000000000c95c5b063636cef7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Am 28.05.2025, 06:54:22 schrieb Daniel Scherzer : > 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 >> in one of my libraries, but I had to settle on `@deprecated` for the wid= est >> 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 = the >> implementation. I don=E2=80=99t understand the complexities around the >> implementation, but is this something that could make it into 8.5, provi= ded >> 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 classe= s > 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? > > =E2=80=94Daniel > Hi Daniel, Hi Ben, Tim and I ideated on this topic before, but we haven=E2=80=99t gotten furth= er yet. I wanted to share my notes though, so that you have them as one idea. Its not more than a brain dump though: - Deprecated classes - mark the following elements deprecated: - constructor method (what if it doesnt have one?) - public static methods - public static properties - public constants - not public properties or methods, because the message is already generated on new DeprecatedClass - during generating the message see if its classed based and slightly change message to indicate its a class based deprecation --000000000000c95c5b063636cef7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Am 28.05.2025, 06:54:22 schrieb D= aniel Scherzer <daniel.e.= scherzer@gmail.com>:



* 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=E2=80=94Daniel=C2=A0

Hi Daniel, Hi Ben,

Tim and I ideated on this topic before, but we haven=E2=80=99t got= ten further yet. I wanted to share my notes though, so that you have them a= s one idea. Its not more than a brain dump though:
  • Deprecated cla= sses
    • mark the follo= wing elements deprecated:
      • constructor me= thod (what if it doesnt have one?)
      • public static = methods
      • public static = properties
      • public constan= ts
    • not public pro= perties or methods, because the message is already generated on new Depreca= tedClass
    • during generat= ing the message see if its classed based and slightly change message to ind= icate its a class based deprecation
--000000000000c95c5b063636cef7--