Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126931 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 2654B1A0118 for ; Tue, 25 Mar 2025 08:45:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742892180; bh=gooOkzX4aO107B4Ij7kASsupZXYi32bF/CW0s+suSV4=; h=Date:From:To:Subject:In-Reply-To:References:From; b=TH4zUy7FZ6GrlALkBMzFd+lseirwmIufRsQuzHxiRzOJqPcYVXNvxkaeilmtpTWLc UFALKwQqFfEiM4YZd3ngL03lmIEfu6ucEjCHG+GUvUOj4q0w+4nBCj3R3wphzRfO2e uMlBjoWthDRdI2OE+RPciaAeKY6kOs4AzFkNhwg+Hq71WKvE/VY2bu6+uBoVPoAgfG JHenMZc8TE7CK0aelGrLewcun7VVa3bdxJS1Uefdt3xQnhrf0JimtaoK0WJmUtplKn PcBu9uwFLvc1IRCOgpf8XeHFVJlWvMW5gYj/paOUFaXuDSjpg7u475HOoSQpJoS2Jq 7jDHvjd8MUgJQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 19AD9180083 for ; Tue, 25 Mar 2025 08:42:59 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b6-smtp.messagingengine.com (fhigh-b6-smtp.messagingengine.com [202.12.124.157]) (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, 25 Mar 2025 08:42:58 +0000 (UTC) Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id 57571254016E for ; Tue, 25 Mar 2025 04:45:27 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Tue, 25 Mar 2025 04:45:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1742892327; x=1742978727; bh=tzd4kktJWKhrz2HRllwNTjDAKF1Dz60cEBC5xtPKb88=; b= MmHcFlMFQ8ZyPkf4lTPiBdeOSy/vxkdZvQRCF4p8BQlzHL+865Vie6NiiCF5I5GF GhhqVTJ6gqZqdi+Ko295LZxv87hAKGNXiYFHfLEVciKviJ6BCfHPzwPmzR4kTxQZ 83kty/r+mFyo84h1a344+XPkBGY5SA2hh5McQ/RpYBT7RmR4/q2umXj8CYpHUcgP TyTWcHzTyHON/KWy9ZbJK8ONk+5pYdU9cLUzIZVfNBlTXlXRv6L0skTlULDjyxDc QdN1QyoLvdSOkEbXCgl/KUJh2TD2x7rNey8p9jvkkqNP1vmCHnt4LPMt4JSmnpfw TtjbZSn8Gzz6tAGR4+IFug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1742892327; x=1742978727; bh=t zd4kktJWKhrz2HRllwNTjDAKF1Dz60cEBC5xtPKb88=; b=HCO5MBpLC+bujpmFW 4/8OQ2dVwZNcXe4Cy9O8XLecuLheveOOjBScF/D9so/ufKdhOrBgHSIxe4tCtT2r tsxDj8reued8mY0jNUa0lF/EImyy74qehYFJL7VGs7YtIN0hzWVCW+6n/RCnEWSy VF1Fm80BIroz9bJzAJtr5K3lASA6NSYtJXoo4PaQdDtfusVdDwqk+T1Rn6W8lTLx D2JL5NASkts+T/mEqIEz4GJNTEGdEenAy/DtGMs+EDg1fJOibStSnagQhpyrCfL5 FG0UaKKC12jRP3+yhY9II3Oxh9Y4yie6eybSwKlo3KtKtDKK6PB3+jt4aQHNtDzS dTsAA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdduiedvvddtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggv pdfurfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpeffhf fvufgfjghfkfggtgfgsehtqhhmtddtreejnecuhfhrohhmpedftfhofigrnhcuvfhomhhm ihhnshculgfkoffuohfrngdfuceoihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqe enucggtffrrghtthgvrhhnpeehleffteeigfevudetfedugedtudevledugeeugeelheei hfehgfdtkeevvefgleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehimhhsohhprdhphhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthht ohepuddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslh hishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 25 Mar 2025 04:45:26 -0400 (EDT) Date: Tue, 25 Mar 2025 08:45:23 +0000 To: internals@lists.php.net Subject: Re: [PHP-DEV] Feedback for nullc Idea User-Agent: K-9 Mail for Android In-Reply-To: <010f0195cbdcf6cc-8ef65563-7a6b-41d5-88e2-feccb9ff1921-000000@us-east-2.amazonses.com> References: <010f0195c30f8ccb-c7fa839e-ec18-4613-9851-9d96b943dca2-000000@us-east-2.amazonses.com> <010f0195cbdcf6cc-8ef65563-7a6b-41d5-88e2-feccb9ff1921-000000@us-east-2.amazonses.com> Message-ID: <6C2C4F10-4F98-4BFC-8B90-946E69026A84@rwec.co.uk> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 25 March 2025 05:53:30 GMT, Robert Chapin wrote= : >I may have over-simplified the examples=2E=C2=A0 Comparing $input =3D=3D= =3D 'yes' will have the same result whether $input is null or 'none' or an = empty string=2E=C2=A0 So not implying a result type, just want to compare a= literal or other variable to $input even when not declared=2E The examples are fine, I think, but perhaps I didn't explain mine clearly = enough=2E=20 My point is that because null is not going to be coerced by the language t= o either 'on' nor 'off', there's an implied default depending how you write= the expression=2E=20 The following both evaluate to true for an input of 'on', and false for an= input of 'off', but give different results for null:=20 $input =3D=3D=3D 'on' $input !=3D=3D 'off' The implied default in the first is 'off', but in the second it's 'on'=2E >A different example could be if (coalesce($_POST['tick']) > 10) return; In this case, the implied default is 0=2E It's less risky, because the coe= rcion from null to int is straightforward=2E The following all imply a defa= ult of zero:=20 if (coalesce($_POST['tick']) >=3D 10) return; if (coalesce($_POST['tick']) !=3D 10) return; if (coalesce($_POST['tick']) !=3D=3D 10) return; if (coalesce($_POST['tick']) > 0) return; if (coalesce($_POST['tick']) >=3D 0) return; if (coalesce($_POST['tick']) !=3D 0) return; But this doesn't: if (coalesce($_POST['tick']) !=3D=3D 0) return; By specifying the default explicitly, we don't have to examine the express= ion carefully to see what's implied=2E I don't know if I'd go as far as banning a single-argument coalesce, but I= would definitely discourage its use=2E Rowan Tommins [IMSoP]