Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127828 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 935231A00BC for ; Tue, 1 Jul 2025 15:56:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1751385299; bh=aFChopOmHH2i4Jleb/6M7zbwsFqUTsxqp/fx5rGfxug=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=QrBC1EDT7Xhp0C40z48qulxLPlH2zRsCq4YUXWKeajRM/ADvtfGiBnWYbMt49F3U8 7Co9UPSWv38tog83iKLza3ds3Rg1MYyheYi2wmziMEppQPt87dFGjlEu4d+K4xbWFh wKo/gwsN1CNriKCfqCRilCwGWF2kMyvGWor1W4alzsRbYwPsE65cCeLlx1LDu2LFxW LB0zif+U4zmXgV7ILH+FwYnyGsfKqpWl47zvtANTH2uKm2mdUMqwLdejPh+La26RdW F9z3Nl7h+WGhWFYCTgufwqr+2YYyDDKD/cduZsXqXPff4KlYyPx/wujkLcABjgoz6P WwO07dpClHUJA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2B77F180339 for ; Tue, 1 Jul 2025 15:54:58 +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.0 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 ; Tue, 1 Jul 2025 15:54:57 +0000 (UTC) Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-73b1fbe64a6so562783a34.1 for ; Tue, 01 Jul 2025 08:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zonu-me.20230601.gappssmtp.com; s=20230601; t=1751385410; x=1751990210; 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=aFChopOmHH2i4Jleb/6M7zbwsFqUTsxqp/fx5rGfxug=; b=COulh3W+XF/Zpb0ALwDtGjFC1zzqbzPaXzHPXqSpmW3poJGznzwjHAm6qBH3OgiG9a sH+Wo2J7b6qCIoNbHr/qfCbmGfns2xpWGspo/3E4uRgT9mToy3JOJNHOP000CGt14gqi XmSxPyLDZkOylwEgNJpOoQR/hbOL6lprTvU7DaoSYP4C1GFQ9nCXrI5yGsvBNRYr2CKp TvNzoayt0LU7UkCfVrDyZUqs3mbX5iedV4o4S6vgmAG479xw65RkNdwnE9G11Ay5dt2S WkHSGrahP8pVdlR7E0zVNDLR3Cg5dl+QdtSaoAgKXAOcMw6esK30PeG1KVNj79UXZmzL oVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1751385410; x=1751990210; 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=aFChopOmHH2i4Jleb/6M7zbwsFqUTsxqp/fx5rGfxug=; b=jfaNghCQu1majIIhV9UU6aAuQG7lZaZSDWALulP9REDvS2WJFPO+FlQdLE3lERuleh 4OkejtQFeUucQI4KlUbMVRaRhijlpZ/lnqxml8hlYs/xkFwvjB5ZpooiloDLouwx2dvG VFQTsU4NaBuNdB1nfUcL4zLWxpdLi2aWXAIIUqQY+uitXpkcSqEj9eNYfFr/O5uxIKux LZC4xsgwSsRPGRHwEoIXIgl+7FTIWglE6HeiULPkSLJujT58iLgGKEr66XpKeDbt/eI6 4W6iGpxGE7oKUXQyjIq4O6atACuQqrioB/xKkPMR8RLV3/ZpiZxRf5So6VLpMuz3uArD dOIQ== X-Gm-Message-State: AOJu0YxRPUVii39GTdwKcr94pJD+BiaMgdeZIjjWc0xVRP73+39D5wqd NPEn4yG5/XnpQ2UFwhHPJwGFH9QmmVxLRpHK3d++miQB7uv4r1MjI9DavIE8FudxEJon+yGH/mM 0m4KNfFYCKacyFMnVkdtEU01huERmAyEaHP3tqXZuvnd1zO9PTHiVrnE= X-Gm-Gg: ASbGncvV8yKvVyeTXas/BJ1PdbTPYrWZo95zzNSQh8kaHSmHeidv2ushfOAVH7Gktez JH4UpC+/2oSeTQ4Z8AVk7FMlSSS13kbs0b9dWOB/WX++dc8fs2VFTHBi50irPWvnLU7/tP98J61 jkyJJpxXjT7ksU1xy9cWQEWtQEyqBXLhFwzkNx7JfglpK6Uw== X-Google-Smtp-Source: AGHT+IEDa2ZskKaONo3tQEphEPSObzKlno4nzmDQwrfNIvop9jS3rui2ZGzVPXgEcCBTqNJt+G2RV4E20Lb5jKePrxY= X-Received: by 2002:a05:6830:4197:b0:731:e808:be5f with SMTP id 46e09a7af769-73afc6f0eccmr12618422a34.28.1751385410094; Tue, 01 Jul 2025 08:56:50 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Wed, 2 Jul 2025 00:56:39 +0900 X-Gm-Features: Ac12FXxXOcd5BnsBqcqH9hMvEeq_98EwETjO6H0o-meW7y9RG68nfmAsID8dMo4 Message-ID: Subject: Re: [PHP-DEV] Expanding the scope of the #[NoDiscard] attribute To: =?UTF-8?Q?Tim_D=C3=BCsterhus?= Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="0000000000003be3940638e0314d" From: tadsan@zonu.me (Kenta Usami) --0000000000003be3940638e0314d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Tim, Thank you for your reply and for the clarification. As one of the RFC authors, your insight is very helpful. I now have a much clearer understanding of the RFC's intent. Your point that #[NoDiscard] is not meant for every pure function, but rather for those where ignoring the return value leads to dangerous, hard-to-detect bugs, makes perfect sense. I agree that focusing the runtime check on high-risk functions, while leaving most pure functions to static analysis, is a reasonable approach. Based on that criterion, I understand that very few built-in functions should be marked with #[NoDiscard]. To give some context, my initial proposal was motivated by the ongoing confusion around the semantics of the #[Pure] attribute in the JetBrains stubs for static analysis. I had hoped that marking more built-in functions with #[NoDiscard] could help clarify the situation, but I now see that this is not the appropriate goal for this attribute. https://github.com/JetBrains/phpstorm-stubs/pull/1730 It seems a different approach is needed to solve that particular problem for static analyzers. Thanks again for your time and the explanation. Best regards, Kenta --=20 =E3=83=BE(=E3=80=83=EF=BC=9E=EF=BC=9C)=EF=BE=89=EF=BE=9E=E2=98=86 Kenta Usa= mi (=E5=AE=87=E4=BD=90=E7=BE=8E=E5=81=A5=E5=A4=AA) github.com/zonuexe ; https://tadsan.github.io/ --0000000000003be3940638e0314d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Tim,

Thank you for your reply a= nd for the clarification.
As one of the RFC authors, your insight is ver= y helpful.

I now have a much clearer understanding of the RFC's = intent. Your
point that #[NoDiscard] is not meant for every pure functio= n, but
rather for those where ignoring the return value leads to dangero= us,
hard-to-detect bugs, makes perfect sense. I agree that focusing the<= br>runtime check on high-risk functions, while leaving most pure
functio= ns to static analysis, is a reasonable approach.

Based on that crite= rion, I understand that very few built-in functions
should be marked wit= h #[NoDiscard].

To give some context, my initial proposal was motiva= ted by the ongoing
confusion around the semantics of the #[Pure] attribu= te in the
JetBrains stubs for static analysis. I had hoped that marking = more
built-in functions with #[NoDiscard] could help clarify the situati= on,
but I now see that this is not the appropriate goal for this
attr= ibute.
https://github.com/JetBrains/phpstorm-stubs/pull/1730

It seems = a different approach is needed to solve that particular
problem for stat= ic analyzers.

Thanks again for your time and the explanation.
Best regards,
Kenta

--
=E3=83=BE(=E3=80=83=EF=BC=9E=EF=BC=9C)=EF=BE=89=EF=BE=9E=E2=98= =86 Kenta Usami (=E5=AE=87=E4=BD=90=E7=BE= =8E=E5=81=A5=E5=A4=AA)
--0000000000003be3940638e0314d--