Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126934 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 A25911A00BC for ; Tue, 25 Mar 2025 16:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1742920818; bh=gA0yGjcJG3+HvDA1mtLETgsF4058QVE8Twk0HV1SuNM=; h=Date:Subject:To:References:From:In-Reply-To:From; b=OfRlLuYrMFrEyp6SkrQsykuX17ERIkcQwWOEI6skQj2rfctLjiApYUtK29pdcfZ/F w1tN+b+tfQW5ZuPCuZ8Ef/pD8PNMRir7zoxmlDwsCgGMOcnVFZyWgjVHP646IeHaXE Lr5t/t4Jg0NEmE96JWATzYGoJ5jdi1udbHQn+sIeYu25mscpoWHbk9FgG2zlpTDRK1 xM3qZwzDa/EEzt5iDcPdPZhvcM9ZNgH775b6itJ0klVB9n32tMBsdCNwB5pijk/o5c EFBZVJUHZ2K45ZPwaUX/iea0/Ooy0RexdVf7YustVRKT5rMamJKDEpLDUv8wVcWP5f yC6DwzjrRD+Wg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8EEAE180037 for ; Tue, 25 Mar 2025 16:40:17 +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=3.0 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,FORGED_MUA_MOZILLA, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,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: <010f0195ce2f5cfc-db04f9b8-7491-4451-8153-aa8b64dde290-000000@mailer.miqrogroove.com> Received: from e226-2.smtp-out.us-east-2.amazonses.com (e226-2.smtp-out.us-east-2.amazonses.com [23.251.226.2]) (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 16:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=qxgm6rwwab7twixglbexlc5btumk6x2k; d=miqrogroove.com; t=1742920965; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=gA0yGjcJG3+HvDA1mtLETgsF4058QVE8Twk0HV1SuNM=; b=k4Uol5XxF8BosFhGdWQ9IJ2EnMaZkoZKgy/IYazYANoQyV3HLNHjs+mMVytucEXL AalFU9lhjpuZx1zD4spYShZgU8xmJgJqQiLomJUO+kaC02QUzTt6Tdk/xEGKeyb/H92 7gCowE6hQcn0SsYgYSRiE30STUfqmeNAcDnhRgqu2kfEHEpGQpR4XS/gP+UHqNviVQx 6FJDhf2TnWRavSyvaG1fKFai8w9UlDLoNNHoGDXmRhAVzcSAfarg61XXk8UfIre98lI Ev+BWA6J5EU5SnRO+rjZljX7OUN57jvNKAIgD6voOSj8bGXPGcJcrSdR3jmVrm/++YS b5p8GrKi2A== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=xplzuhjr4seloozmmorg6obznvt7ijlt; d=amazonses.com; t=1742920965; h=Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=gA0yGjcJG3+HvDA1mtLETgsF4058QVE8Twk0HV1SuNM=; b=M51WaOZyZT0KaWUUlJ+cc9IXQQEDvyY0ozkYmtPDHIai6F1utfJWp75jqMtC2MmM m5xErq7bPo2IiUhUzSnHzIdPtGfNJPzXHR2S/jr6XqFQpjI00ExzpJ0VlneU8cppvGP LuenRjT5z/ud+tvqKC5FFn+o0dwfHbTycZPWrAhI= Authentication-Results: solid; auth=pass (plain) Message-ID: <010f0195ce2f5cfc-db04f9b8-7491-4451-8153-aa8b64dde290-000000@us-east-2.amazonses.com> Date: Tue, 25 Mar 2025 16:42:45 +0000 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Feedback for nullc Idea To: internals@lists.php.net 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> <6C2C4F10-4F98-4BFC-8B90-946E69026A84@rwec.co.uk> Content-Language: en-US In-Reply-To: <6C2C4F10-4F98-4BFC-8B90-946E69026A84@rwec.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=miqrogroove.com; s=jan2022; h=subject:from:to; bh=gA0yGjcJG3+HvDA1mtLETgsF4058QVE8Twk0HV1SuNM=; b=NpKrzqGsyQz9Jy8nvaWKAQTPjYIlS6pQ40SInsTFFBsp2gQYy4KI/MVVCG7f99iAJs+tdLQHxk ZNXxi+1kaODsUiAFyBbrJFqIaITh40GsXiU/SbDl0V0xk0xip21iCY5fXdPRhBjbQkcLsBE9KPI+ 4/9ycCJZHiubufVXC5UZAxpkuvv0DS7cYcWWPdFswnmDpGZPCXb25jUtDzRUHGFQJHqI/dCtBJ9G iMj+3kAOwUu0gFh1Ei26nTk5LTFroXFdiopuXKV4j2ILI+yB2gLFXMsOMAqls9BCrw4eiOLoZsY4 TP0SAP4CvsQ/1E5o9w8MutNYivvrfTg/ndqvtAjw== Feedback-ID: ::1.us-east-2.QbD2JL3ZnDgkTsZd92lLMWNtgKUB27BqpIzxIe67R3Y=:AmazonSES X-SES-Outgoing: 2025.03.25-23.251.226.2 From: php@miqrogroove.com (Robert Chapin) On 3/25/2025 4:45 AM, Rowan Tommins [IMSoP] wrote: > My point is that because null is not going to be coerced by the language to either 'on' nor 'off', there's an implied default depending how you write the expression. That kind of user mistake is hard for me to wrap my mind around.  I don't expect a missing variable to be identical to a string literal.  So a unary coalesce seems perfectly natural to me. > The implied default in the first is 'off', but in the second it's 'on'. I thought the implied default was null.  $input === 'on' is only identical for 'on'.  $input !== 'off' is always not identical unless 'off'. >> A different example could be if (coalesce($_POST['tick']) > 10) return; > In this case, the implied default is 0. I thought the implied default was null.  For me, potential confusion would arise in situations where a database query might return a null value and I have to choose between is_null() or coalesce() or ($a ?? "").  That's the situation where returning null doesn't accomplish anything and the single-var coalesce becomes the wrong choice. > I don't know if I'd go as far as banning a single-argument coalesce, but I would definitely discourage its use. The feedback and the thoughtful perspective on user mistakes are helpful.  Thank you again. ------------- Robert Chapin