Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126292 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 AD6FC1A00BC for ; Wed, 5 Feb 2025 10:58:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1738752947; bh=+hyNyaVLTfhX3aqMYli75GtWJ29yeReMOsb7QVpw4O0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XjPjZAUJZx/C13WeqtzsOkUZsDykHyO1Lj0aTDKE9b1AjImPG8FXmKyETO6K824Pn 6tCVWLxGRG1p10jCjyyEhIDA2c2eA1l0409LJv280HE7tpGEHilJ//TI/+DhH0SHot xAs2qFsqv83ty8inJ9pQ9ULwAjEO46sCn0H3zI/Tw9Pkxxg7ZELttiHOs3xst6UCbZ Y0sSol4wX59zvfxtYzsyn6YLDHRQSgcw3zYCOOcXyfJmCdztN62Lm1BxRvGNV81vTq Qs8eBucsoFo8dvvPe1Edn06UjHCp4ePWupXQ6nAMRrHCL4vHTL57Wga8wPSUcdP/vy Z0LfRVaEXOXAQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E956F180080 for ; Wed, 5 Feb 2025 10:55:46 +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-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (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 ; Wed, 5 Feb 2025 10:55:46 +0000 (UTC) Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-5dcd3454922so2341797a12.1 for ; Wed, 05 Feb 2025 02:58:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tideways-gmbh.com; s=google; t=1738753111; x=1739357911; 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=+hyNyaVLTfhX3aqMYli75GtWJ29yeReMOsb7QVpw4O0=; b=O1vg+Av9JeO+OSclDcYqxe89fRac/qEWVw+Xv1Y/cbsQsOe/krKPt5PsCirong/Jcx pDU5eCbrhwkarhqO5yB/gzLNul8/Ym9GUVp/nTmTRF6WFLqNX56V+sjgzSttYKlEP62T CAVdV66fV3fE1UWnY87Gvlbwt3SKB8qlHj8ZzCW7HLLR8mDjwdbP7aUl/1bAP8pVJ/T7 ng4BTwftTS0KwEq/Quo1b0eB7EZ4Br4YtcJEJCdVvI8G2wxHDPpGkJfjlCdt8huinm1y Tn0n6c30fq3DKgUScnBiLtjxnMM0mXfk2u6z2tyH4UkYGrKrw94BNJoWHiVVKbCKqrkj scfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738753111; x=1739357911; 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=+hyNyaVLTfhX3aqMYli75GtWJ29yeReMOsb7QVpw4O0=; b=dcQjnfXa2pclgouAs7CAtq52/Iy+zTLlt2dUacthje6Sm2dGMDrEkkxFEmtCLvr/hH 84iA2nNfqLyXqOrhbVnzIAqCrZWyjVwjsQFZnqhhBUEIFKVN3iwvamtF0FqQShnKTR3q OUZ9glmdUzDsIxYGOX/ak3xVEIlCnCqZawiXFh40fDx0ZLXAT+YiFWxQYul/YaweDY4X wxNc16p+ACr6rd/EFqw8H7PeLlBgC3ZEldCytsSTPN6yP7WhbeY+2hQ/G2A4O2ENSyaj vJBt9FoVBLMEmvf3bhqz4xlSJ/6zDJvF6+nl1dmQuD+YCVWsjIF35cTHuanO7dNpikhD VRyg== X-Forwarded-Encrypted: i=1; AJvYcCVnubaUOIrSOaNwNFE0GC5oHBENvinVudhKMjxXrSEEAI8zrvjo9kAV3Jx4LsXkuFYt2a7hclERdgI=@lists.php.net X-Gm-Message-State: AOJu0Yyw9WQ0vqEi/p5kj7DFPioRB2PnrDLcaetGA0nzGn57PjaYSgTZ mv9k4OBe6CBbwx/Jgrqsu6DCvGvoKe2wBdbaHevKrcahdZlgCdgG1ajKOMsfqmcPUuNfoG+ciKM JL0r2yA6rsdih8I9twtaR0CUHHtXa99fcdVeAAg== X-Gm-Gg: ASbGncv40piEcYpGEHRASnAcPtyAwdtvmpzL6vSqgBWN4nE/o2RxMLRq2YB/b6Vwnlm C8sbGVDGCtAytmg4ga4Fn8kXuRqxBb8LW3FX9avV1RXlhiykzNI0LSa8Ex5MHh1Txx+K7BTQmSw == X-Google-Smtp-Source: AGHT+IGDCiFckPNWsv1VCnnJxCwl4scMhPbOhvwh7wRWy2Eb0zMLPqALk1ubM2aG9nPgtUBeB/X3klUGeMvzGShnk34= X-Received: by 2002:a05:6402:350c:b0:5d0:b51c:8479 with SMTP id 4fb4d7f45d1cf-5dcdb7179ccmr2981100a12.10.1738753110722; Wed, 05 Feb 2025 02:58:30 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <7175feba-85ea-ce60-f89c-36ea1a7ed574@php.net> In-Reply-To: <7175feba-85ea-ce60-f89c-36ea1a7ed574@php.net> Date: Wed, 5 Feb 2025 11:58:19 +0100 X-Gm-Features: AWEUYZnTEQH5INBSUPJ74O-gKXY0cJuj1FCrm_n00Toj6ho3VEhQOO05_4JtLgY Message-ID: Subject: Re: [PHP-DEV] RFC: Marking return values as important (#[\NoDiscard]) To: Derick Rethans Cc: =?UTF-8?Q?Tim_D=C3=BCsterhus?= , php internals Content-Type: multipart/alternative; boundary="000000000000847b65062d63016f" From: volker@tideways-gmbh.com (Volker Dusch) --000000000000847b65062d63016f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Feb 4, 2025 at 12:10=E2=80=AFPM Derick Rethans wro= te: > What's the reason why this emits a warning though, instead of throwing > an Exception? I'm sure you thought of it, but it would be nice to have > that consideration mentioned in the RFC. > Thank you for the question, I now added the missing reasoning to the RFC text. > A E_(USER_)WARNING was chosen over an exception to avoid BC concerns, as throwing would potentially break existing code that "works as implemented" and because this is only a warning in the literal sense of the word, given that the function executes successfully. Given that PHP uses Exceptions only in hard failure cases, we found it to be more prudent to go this way. If users really want, they can suppress/ignore this warning without adapting existing code, e.g., using the proposed (void) cast. But the main reason was to not cause hard failures through exceptions. Kind Regards, Volker --=20 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 --000000000000847b65062d63016f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Feb 4, 2025 at 12:10=E2=80=AFPM Deric= k Rethans <derick@php.net> wrot= e:
What's the reason why this emits a warning though, instead of throwing =
an Exception? I'm sure you thought of it, but it would be nice to have =
that consideration mentioned in the RFC.

Thank you for the question, I now added the missing reasoning to the RFC = text.

>=C2=A0A <php>E_(USER_)WARNING</= php> was chosen over an exception to avoid BC concerns, as throwing woul= d potentially break existing code that "works as implemented" and= because this is only a warning in the literal sense of the word, given tha= t the function executes successfully.

Given that P= HP uses Exceptions only in hard failure cases, we found it to be more prude= nt to go this way. If users really want, they can suppress/ignore this warn= ing without adapting existing code, e.g., using the proposed (void) cast. B= ut the main reason was to not cause hard failures through exceptions.
=

Kind Regards,
Volker

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

= Sitz der Gesellschaft: Bonn
Gesch=C3=A4ftsf=C3=BChrer: Benjamin A= u=C3=9Fenhofer (geb. Eberlei)
Registergericht: Amtsgericht Bonn, = HRB 22127
--000000000000847b65062d63016f--