Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126391 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 413821ADB3D for ; Thu, 13 Feb 2025 14:17:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1739456069; bh=gob3hArAYfBtaYRznDfWgJ+n4KcX7fQcoq7ZRdXtrLg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=dNkokKOpVmFhw6CK57+d5y2x70gpbpRtnI0J5fQxWJKfe2mTrSLWLKpi2ZEHW+4OZ BXIIvpaEAx+95NnWggELL5ILGxI9zg0hgGF4tPjkSj/WmEGaeQlyZjjrCxA0V35At8 Mgbd2oKOSYUPWxlxqbW7WWt6IiPRWLjePMd2fq92n7jti53pnf0ne1hfSWZyw36xXk LkR6dgsaZAAIcggeWEZOkA8996kLu2gYABI99d480jiGmqU6I8iURqhXeG/7xeXo74 xW0C62ulK4lwNVH+2ku0qxDOf4XBwfyFX3fc3dvY5pnIBokoYIcXEWJ+EdM/UifQHJ l+Fr9O+7nBEjQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C609A1801EA for ; Thu, 13 Feb 2025 14:14:27 +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_20,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:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1739456227; bh=xCQD+H9z5BHEv76WQyY9ra9PssMl2brgODSi3Tvf9ZU=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=GXu+YIys0aWtGJ+xr5HUj8oiv4ISTEW5WbaqrokaOrIcSmAq30SHI+N0leXbUbP9q lAsyxGOOGF/1iM1RViw/lvh4Os1xZt7zJ+xCRHdnjOwKF3kKM6pGKuMdPSLLjQ+ujH L3jcEWdglwHyVO7cVGDxdXki1Q7xJeWgcvZ8M5MvF+j4F9SMpFjX21XuQAvECCxxhk jLJXGA5WRm0Ia3QeH06pcZQgKw3t+kInDUECMwqScy3bcBAh9AxNryKezTcUtHpNRh X50C5IBkbmIjWT8JGdPEq64smch8sAF9nYz0z+ae9w+MZOqF6WgoIQkCqzyJ+No1tH vFANIVUvSIswA== 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:17:07 +0100 To: Eugene Sidelnyk Cc: Jakob Givoni , volker@tideways-gmbh.com, PHP Internals 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: <26e4269882bd624a7cb332d51d1bc3d8@bastelstu.be> 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:49, schrieb Eugene Sidelnyk: > I'm just wondering how the new attribute that defines behavior (not > just > additional metadata) will fit into the rest of the system. See my reply to Jakob: There are already several attributes that define behavior. > Do you think it's reasonable to implement "non-discardability of the > returned value" as the attribute? Maybe new keyword would be better > solution? Yes, we believe that implementing this as an attribute rather than a keyword is the right choice and the reasoning is similar to the `#[\Override]` attribute that was added in PHP 8.3: https://wiki.php.net/rfc/marking_overriden_methods#why_an_attribute_and_not_a_keyword With the exception of error handlers, applying (or unapplying) the `#[\NoDiscard]` attribute will not affect how a PHP program works. It will just emit a new warning which when suppressed, will not affect the program’s behavior at all. This is different to return types, which are relevant due to the Liskov substitution principle and where changing the return type would actually result in a breaking change to the program’s public API. Best regards Tim Düsterhus