Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123568 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 E9F8A1A009C for ; Mon, 10 Jun 2024 17:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1718040207; bh=R446vz0WT/+OS1O/MpbfcmMrDHiSg1nXKKKbPvKFVTM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=QKHGkid0bJY1cJmHBD+XzuZQgzRqqaszWgCp1MYRrfgyRgk0mGsjuzRLR5EgG1RUW 1ZOA7uui0WfR9lEEnkj/nGyKh9Tbmy9JJyNhDnVTdTRt+Z7LTUNCBJiTkb51UpRxWK +pGC2wrfQpQF/BRcUyWsO/+fGDO9p/3sY/j+FoP8M0K3V8GXmsuLEi7ei+pSuk/uNB maa3YqujGeuOgMCPYcHRHeNa0LlcehVwf6RT/GXNj7tokqRelHI8RGzsWZ0/os1Mpw ikwHfJ8kPYIv2A7aYvMA/nozixfENVtoXJYbIUmIVuzAQv6yW45/luJK2x97OSOC+y offySu8113Ohg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 00C101805C8 for ; Mon, 10 Jun 2024 17:23:26 +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 ; Mon, 10 Jun 2024 17:23:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1718040136; bh=zrprgzVmH8n1S+8meWTxAnQE/yQ9BsznFtE+KknZ2ps=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type:from:to:cc:subject:message-id; b=FklECAoYd8hDqGdYqDWoQ7nECPh0DulFtjKghuCUq948LIPNzI8knYTU8p4I3FR+E VwCrd5IOWEcDZq5aSL53BV/uG8VMLMhQtd+Z8/Tzrp1IzBNrHDVGHQHh+f/NfNvYT+ XFMyOPjHBmp/tnuWeboTtoMUvs4PuEvOCyD9x9SESUBUpfnJcLdU4xJnDz9Fk3VJ3Y /TkJdSyfElzvpNwWqbpTVytAv3rwxgBBfnlAyHCjuzAVZahUmuvLZS/3mCf64q6R7i iPPfMjEYmF1qdZULFWABon2j1nbubqfyjIGnsAY71JZcNa0j+Z/5JCs18eQ2mnrdID CUPPPfxc3N49w== Message-ID: <4b6331be-e00c-4719-b3fe-d9d70995fde2@bastelstu.be> Date: Mon, 10 Jun 2024 19:22:12 +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: =?UTF-8?Q?Benjamin_Au=C3=9Fenhofer?= , 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/5/24 10:16, Benjamin Außenhofer wrote: > Tim will finalize the implementation PR now and work on its merge in the > upcoming days. > During review Ilija pointed out that adding the internal ZEND_ACC_DEPRECATED flag was skipped for abstract methods and interface methods, questioning the decision. The decision dates back to Benjamin's initial PoC implementation and I've had a short discussion with him about this, with the result that it's probably best to ask the list, as it was not specified in the RFC. Currently adding the #[\Deprecated] attribute on an abstract method or interface method does not do anything special. It only applies the attribute, which then can be accessed via Reflection. It would be easy to change the implementation to also apply the ZEND_ACC_DEPRECATED flag. This would have the following consequences: 1. `ReflectionMethod::isDeprecated()` will return `true`. 2. No deprecation error will be emitted. Neither when implementing the method in a child class, nor when calling the method of the child class. (1) is probably the obviously correct behavior. For (2) the reasoning is as follows: - The implementation relies on the pre-existing behavior of ZEND_ACC_DEPRECATED, which does not emit a deprecation error for overridden methods / implemented abstract or interface methods. - If the deprecation error would be emitted when implementing the method, then the error would not be actionable. Child classes are still forced to implement the abstract method / interface method, thus there is no way to change the code to not emit the error. - It is not obviously correct to inherit the deprecation when overriding a non-abstract method of a parent class, just like attributes themselves are not inherited [1]. Abstract methods and interface methods should keep consistency with non-abstract methods. The reasoning why it's not obviously correct to inherit the deprecation is that due to not inheriting the Attribute, a custom deprecation message would not be applied. It goes without saying that IDEs can opt to suggest adding the #[\Deprecated] attribute if the overridden method is deprecated itself by means of the existing code diagnosis functionality, making the attribute on abstract methods / interface methods useful by that means. We plan to adjust the implementation to also apply to abstract and interface methods with the semantics outlined in (1) and (2). Does anyone have an opinion about this / does anyone disagree with that decision? Best regards Tim Düsterhus [1] https://3v4l.org/GIZRj