Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123948 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 B8D121A009C for ; Thu, 27 Jun 2024 17:55:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1719511011; bh=9DTDRgUZCTQTmy7gL6v3fZGsso9uU/PoMwzKookiXGU=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bb3OtkN1JzWxf1rG8cQOYgWpcWJAc5TaklWWg6cDfnsHo57RLa8aiaGzk6dIvlybG A4uxIyXL+4c0DABORUeI8rD0O3I+6vycwyL1P4KcoXC3z7PK5eqUWrDuaVLJhWulyF WIW3a0QSzMlUuR0wSL+bQBhFsMMh8hoP9C944dZJHEMQujMcsSeR+pbCbAksiVnmaq 8JfCBruBZv5cGJ8/DowL9v3YBhdNr69+TGcwLrPyXKwlWqIlNkkAtdWWNsZ6x+Iwyi mh+TJFdx1X1imCrmuxKRYWCS84YMb0A3eeS1WwFrggazSqXV3Gb9ngs5HbxLwEnmwQ vB+OkhkPzmcHg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8CCF41810B0 for ; Thu, 27 Jun 2024 17:56:50 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (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 ; Thu, 27 Jun 2024 17:56:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1719510930; bh=LVIYJ/lsXS0q1kSeo67othekISGETC80ddZO0WyqrzQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=jBGxCfbcqmn0o76Kqyb8krwpQZgntfVWHAmNotrs0pFSAL+sLzaJe/8H6FTY5xmjx A77kiaH40OEaPzq6YqIzCgcb7bQ6YKhCmTVSWHfrx+9rM5hOOnHy3G2X/Zp345Vnxh koHASh4+c3i1C6mrYXkkZijHsBCNXgB+hn/GnLqOYgP6Km/iyvt4ViEGGa3UU71V6N +Wt1b6uZs4b9Yg5Y/pRG/p3Y+3sdVlxX70O1u1RSVmwzfBlyB7UBo/ETmpvEps7FQc hZiB3J+VwO8sM6knmnfLTZYFyJD7Yh+4xLa7xVuej444yAZSq9Pja3WIYEo6XJ4Zd/ B4TTzm1aUSmcw== Message-ID: Date: Thu, 27 Jun 2024 19:55:29 +0200 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Subject: Re: [PHP-DEV] Re: [RFC] [Vote] #[\Deprecated] attribute To: Nicolas Grekas , =?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?= Cc: PHP Internals References: Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi On 6/27/24 13:10, Nicolas Grekas wrote: > That's sad news, because I keep explaining why engine-triggered runtime > notices are a terrible idea, yet you're planning to add more of them. The > consistency argument Tim wrote in another email isn't sound to me: > consistency with a bad idea doesn't make a good idea. I've yet to hear a better solution for deprecation handling that does not involve third-party tooling. Being able to deprecate functionality is a core part of being able to evolve a programming language and just a note in the documentation no one reads anyways does not suffice. > In the hope it may be used as food for thoughts: when we use `@deprecated` > on a class, Symfony's DebugClassLoader throws a deprecation ONLY when a > class *extends* one of those `@deprecated` classes. Thank you. I'll keep that in mind if/when we'll actually start working on an RFC adding support for deprecating classes. > For the runtime notice itself, we decide case by case among two > possibilities: either triggering the notice just before the class > declaration, or in the constructor. The reason is that sometimes we have to > load the class but we don't want to trigger the deprecation because loading > the class doesn't trigger any side-effects that users should be warned > about in relation to the deprecation. In such situations, we trigger in the > constructor. I agree that just loading or defining a class should not emit a deprecation warning, just like loading or defining a function does not emit a deprecation warning. > About Attribute::TARGET_CLASS itself, not adding it right now will lead to > a situation where userland will have a hard time writing code that's > compatible with both 8.4 and 8.5 (assuming 8.5 is the moment where the flag > is added): using #[Deprecated] will be "illegal" when running on 8.4, yet > legal when running in 8.5? > > That's another reason to allow the flag right away: smooth upgrades. That is a fair concern. I could imagine backporting the Attribute::TARGET_CLASS to all supported version if/when support for deprecating classes is actually added to the language and semantics are clear and considering that to be effectively a bugfix then. > My suggestion is quite restricted, and that'd solve all my concerns: it is > to enable the flag right now, and to add ReflectionClass::isDeprecated() > right now also if you want. But don't plan anything more on the topic, > except maybe a deprecation notice when *extending* a #[Deprecated] class. > But nothing more please. No runtime notice when loading the class. The PR implementing the #[\Deprecated] attribute will implement exactly the semantics that were decided in the RFC. The implementation is already be complete and is currently pending JIT review by Dmitry. Assuming no change requests during the review I'll make a final cleanup pass and then it should be ready to merge. Anything that is not in the RFC will (need to) be part of a separate PR. Best regards Tim Düsterhus