Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126497 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 38F081A00BC for ; Mon, 24 Feb 2025 15:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1740411096; bh=4iBX90h9Cm7jSi64j/W0XwqWFMkTja121oCwdglq8vs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IqKhuKfPinnfshs0yhlJvcRfp5xvRxGm9Nr0gXCWlsU/q7ogc92Qo38lpl2h7bTSR I55BbydEIYKZmD4MLbbeaJ3ORZLTNzK6iFmoG3Vq2tm5dfMSoI1Etk2pDQRxvuheTY fi2okEwbdUOcp3Sk6k0MlHNn6bPvjFBGbwWNO1esjyR7hjY5nT4FFRo++VYjiILY1H ZVfUhGtW27IrgDCG0psKsKc+W5j6pZpA5rUI/tpRHCT1LRBvsznwzm/Xv/7USPeMTa 18F5x+VjNrMF4RdAFN3jNczf6RVNAzqG/+Jyn0ZTrBzZIMUPhymzdg8auC/btyTSSQ LcOez9doQkpXA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2EDAD180068 for ; Mon, 24 Feb 2025 15:31:35 +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=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.52]) (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, 24 Feb 2025 15:31:34 +0000 (UTC) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5dec996069aso7325638a12.2 for ; Mon, 24 Feb 2025 07:34:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tideways-gmbh.com; s=google; t=1740411252; x=1741016052; 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=4iBX90h9Cm7jSi64j/W0XwqWFMkTja121oCwdglq8vs=; b=YbdaYSNQCL1HeVajyTPUdDtpktj+hTi0D9rnbfdYH4oqknwWo3FMn8CaWK7rSFWpN6 r3t9b25/PAnyuTzgY0ru23hBZyF9S5QjcLcR3/51DxLZUFv5bcRRS/HYrtdZPqpeg6oI 9VAobAoFv6x/YkHtgcNDcmX6ujUMrUf1ZkLk5cBx9Trqy8R+FRp+HulWU6ykAWqzEJom YhTLKl4qXuP2yPcMhpbnxCCA/dT8boImFLGVvGzI8nHsjpKR6d2GPdkswzybP+ECjNGn AAU6W8Wg7vzTRJfwx23VMpC4BaHnbAqj+6IQQvt9xP9P/U7/WIcAl5g/v/DlDmpadIeN p4bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740411252; x=1741016052; 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=4iBX90h9Cm7jSi64j/W0XwqWFMkTja121oCwdglq8vs=; b=dILI+FmBKdo1x7ZpEw80Cw+e1jlJJ5t12x4FPXr+S6Gn84y/q/LZEhM77ltXii9BP2 Pe3AGm77oSmFM43o9zRLpaQTkTtj/z0X0ItJR4PPqvlnv8xxm1jqTMcnwvPgENNkSFBP zU4VdCo/5xs2YZa0VRA0nTqRHOP3tLm7NiUPVhzrXBOOQDcedlH7NuveTmxKah50va3P 15NloVn1VbFMc3y+JNfqUums5xwXdakXBbZiTKOccJycWFF3+UAb6QRK+DJscKxTijFG wCkTusUe82F1SMZjxg5otbRHcelvimVJryWYBER5y4VdpM+P/lahLsPzA1E6YvYS7hQ7 Mskw== X-Forwarded-Encrypted: i=1; AJvYcCUmnKbQ4Db0k35GtFZeis16YrsMBDCtW5oMPtKGdHH2oEB+mKTNCBlmH2DkTx7o39HCjHfw9cCDP8g=@lists.php.net X-Gm-Message-State: AOJu0YwtCXQ84xv19S9rinhdrwBFU0LWUdSyJ4cGYUXvTqi4M7p+Y/oA PRWldBfLzjuHxNnubOiLOsPvHspTYMsPDsYr7RfoWjFvHb+tsG0D4Sp+xTASsmwnbDuy+gvf/En WmqPfkqDQLK0Vmq7iVGdr92QQFZIAYr9E0t10DA== X-Gm-Gg: ASbGncvPxC8Uq+MQ1dOs92dR+Gg6KYTEyLxpHryX3tmxI4M3qG6vGQIlFVKxSqnLVW/ fCm8bOljI9S4H6DQsb7iPKBM0IA0xTqM68AnwqPm5H/I2s2NntkVsmpBOHX9xO8KSws1dECk2aJ POSsNGrt3BUY2tg2lfDYzDWV97grTVHwCum+NegA== X-Google-Smtp-Source: AGHT+IHfBLpTXQlG4NJIw5jxIqjgBgfymuFkMo0rDYnvL43ORmxEUePdKGLzTt4srY31Ggm6jh2kLujLHQt9hKh850Q= X-Received: by 2002:a05:6402:2750:b0:5e0:9269:f54e with SMTP id 4fb4d7f45d1cf-5e0b70d7026mr12904404a12.14.1740411251731; Mon, 24 Feb 2025 07:34:11 -0800 (PST) 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: Mon, 24 Feb 2025 16:34:00 +0100 X-Gm-Features: AWEUYZmpuJ-D5FFa2QbNV4cs7LBWCqdhUXeclYflehUIo2WTp1qKSsJwOF8Hvoo Message-ID: Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) To: Jorg Sowa Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , php internals Content-Type: multipart/alternative; boundary="0000000000006c8407062ee512be" From: volker@tideways-gmbh.com (Volker Dusch) --0000000000006c8407062ee512be Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 12, 2025 at 10:44=E2=80=AFPM Jorg Sowa wr= ote: > I must agree with Kamil. I don't see practical benefits of this feature > that would surpass the implications it has for the language. We already > have static analysis handling such cases and it can be extended even to > non-pure functions. Moreover, syntax (void) adds additional complexity to > beginners' understanding of the typing system. The second option with $_ = is > BC on the other hand, so both options are unsatisfying. And honestly, I > don't have good ideas for it. > > Kind regards, > Jorg Sowa > Hi Jorg, To be clear: There is no BC break with $_. Opcache doesn't discard variables containing objects, so there is no observable change in behavior from what we're proposing. It doesn't change the variable semantics at all. Or am I misunderstanding what you're referring to? In addition, I reached out to see if Ond=C5=99ej (Creator of PHPStan) had a= n opinion: https://phpc.social/@OndrejMirtes/114040888791921128 - So on top of our previous arguments that PHP shouldn't depend on 3rd party tools for everything, there is also at least interest in having this in core from the tool creators. > @edorian It already exists for PHPStan as a 3rd party extension: https://github.com/DaveLiddament/phpstan-php-language-extensions (MustUseResult) > Additionally, PHPStan itself reports this if you call a @phpstan-pure method or function and not use its result. > This attribute would be valuable for functions that aren=E2=80=99t pure b= ut you=E2=80=99re still supposed to read the returned value. Kind regards, Volker -- Volker Dusch Head of Engineering Tideways GmbH K=C3=B6nigswinterer Str. 116 53227 Bonn https://tideways.io/imprint Sitz der Gesellschaft: Bonn Gesch=C3=A4ftsf=C3=BChrer: Benjamin Au=C3=9Fenhofer (geb. Eberlei) Registergericht: Amtsgericht Bonn, HRB 22127 --0000000000006c8407062ee512be Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Feb 12, 2025 at 10:44= =E2=80=AFPM Jorg Sowa <jorg.sowa@= gmail.com> wrote:
I must agree with Kamil. I don't = see practical benefits of this feature that would surpass the implications = it has for the language. We already have static analysis handling such case= s and it can be extended even to non-pure functions. Moreover, syntax (void= ) adds additional complexity to beginners' understanding of the typing = system. The second option with $_ is BC on the other hand, so both options = are unsatisfying. And honestly, I don't have good ideas for it.

=
Kind regards,
Jorg Sowa

Hi Jorg,

To be cle= ar: There is no BC break with $_. Opcache doesn't discard variables con= taining objects, so there is no observable change in behavior from what we&= #39;re proposing. It doesn't change the variable semantics at all. Or a= m I misunderstanding what you're referring to?

In addition, I reached out to see if Ond=C5=99ej (Creator of PHPStan) had = an opinion: https://phpc.social/@OndrejMirtes/114040888791921128 - So on top of o= ur previous arguments that PHP shouldn't depend on 3rd party tools for = everything, there is also at least interest in having this in core from the= tool creators.

> @edorian It already exists fo= r PHPStan as a 3rd party extension: https://github.com/DaveLiddament/phps= tan-php-language-extensions (MustUseResult)
> Additionally, PHP= Stan itself reports this if you call a @phpstan-pure method or function and= not use its result.
>=C2=A0This attribute would be valuable for func= tions that aren=E2=80=99t pure but you=E2=80=99re still supposed to read th= e returned value.

Kind=C2=A0regards,
Volker

--
Volker Dusch
Head of En= gineering
Tideways GmbH
K=C3=B6nigswinterer Str. = 116
53227 Bonn

Sitz der Gesellschaft: Bonn
Ge= sch=C3=A4ftsf=C3=BChrer: Benjamin Au=C3=9Fenhofer (geb. Eberlei)
= Registergericht: Amtsgericht Bonn, HRB 22127
--0000000000006c8407062ee512be--