Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126390 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 CF7541A0133 for ; Thu, 13 Feb 2025 14:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739456061; bh=pzDFJm3I+5DO/F8TNkT984N1d8yrLFQgScd8og/fGg0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ee89Ve6pVIwF592SpRQsMOe9xbEundPyqIq/LpbUn8UhT2iea0YWqjEdZp6h8L2P5 jRc5P+30QJ+sIXeuJzQ8bF2n/3KUolW9rU8YNL2sjoRRykmykpCDYFn5AnTT0mgxvo mWN6VH+mX2JX4cyJPE8AoLToBrZNPehyOqpmFdCnHWEt9cV48mKZ8A9VtPOM6EqwDP HX1hSW7rZZg1aKm9C0GvsNWMXFYKLTfJVbUQtTWkcrmEzd+R+lPdFw1Bi2RYibEja1 uzMBnRS7XfgGOJyKLaXxNHk064DUJBtOYz4w5V7zDH+VkneI/6u3zPjDCfYTn2+P4Y RfOPkOQH4YqhQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B4F6E180209 for ; Thu, 13 Feb 2025 14:14:19 +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.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No 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, 13 Feb 2025 14:14:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1739456219; bh=UGfqt/cAQbnyOSaG/cbU6UZMylW9VwJNwRiZJVji4LA=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=Ejon3U/sGO2A5gH2MST4XLC+HcZD7ePyP8g0jWK13QQPKR+/sMr0cc2jg6cfJtQZk JW9vCeRGy2PDzKf+KZoZpD0ARsoc5rH2T6HhPv/x7R8Sza6gekrHcEWRHZEfB8+LMn AWuWSTjnKkTCFurvMk+u7yDI5mM0/D2beU5DpmoepcyspDBz+C0xnMn+vAXg74xWRd q3XIxrqTyZ88k069UXtA0/AFMHLX747YSbDbhB0dTV/z9VkULx5r36fZeHMf8+zT9R OFbBEOKYB7qFTVzShv6c7NgZ99OFccmimNtCgKKYTR1jAe6fkukECMl4r4kyiq2Fyb A1cB8ZlnQWFlQ== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 13 Feb 2025 15:16:59 +0100 To: Jakob Givoni Cc: volker@tideways-gmbh.com, internals@lists.php.net Subject: Re: [PHP-DEV] Re: RFC: Marking return values as important (#[\NoDiscard]) In-Reply-To: References: <5c142df3-94f8-45ba-b5c6-af3b4f7caa8b@varteg.nz> Message-ID: 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 Am 2025-02-13 09:16, schrieb Jakob Givoni: > Attributes were added as a structured replacement for docblock props > and I > don't like it when they affect how a program actually runs (as long as > you're not using reflection). Excluding the `#[\Attribute]` attribute, PHP currently has 5 native attributes and they all affect how the program runs. The initial accepted Attribute RFC even lists several “behavior-affecting” attributes in the “Use Cases” section: https://wiki.php.net/rfc/attributes_v2#use_cases. It is probably fair to say that use-cases like `#[\NoDiscard]` do not go against the vision intended by the Attribute RFC. You could think of it as the PHP engine using Reflection internally to do something differently. > 3. Naming of the attribute: I think the most precise name (if I > understand > the purpose correctly) is: #[ReturnValueMayContainCriticalInformation] Yes. Or perhaps `#[\ReturnValueImportant]` as used by the RFC title to keep it a little more succinct. > If we scale it back to mean "Look, this function may not behave the way > you'd expect it to, - the return value may actually contain some > information you might be interested in, so you better check it man", > then I > think it could be a small but useful addition. Let me refer to the “Recommended Usage” section of the RFC: https://wiki.php.net/rfc/marking_return_value_as_important#recommended_usage My rule of thumb would be that if you have trouble writing a good custom explanation in the attribute, then it's likely not a good fit. Best regards Tim Düsterhus