Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117562 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 60846 invoked from network); 21 Apr 2022 15:06:06 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Apr 2022 15:06:06 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6983A1804C6 for ; Thu, 21 Apr 2022 09:40:08 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.2 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 21 Apr 2022 09:40:08 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id t6so4055767wra.4 for ; Thu, 21 Apr 2022 09:40:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:subject:user-agent:in-reply-to:references:message-id :mime-version:content-transfer-encoding; bh=AWSuzXsUQPN7Oj09z+KYxadDAegLQpa6rfwvkMl0StY=; b=hpbFrdy3kCfSu1Ck7AVtmmymey0hKc7jMuRgD3Zy1lh5dKbulATYa+Eo44v9NZxacF 5RWnm+eO/dLt3otlIQz0GrfqLJ5SAgVQED/pql6M+/ZA3lUGp/8Q/6ZMgzpE0z9VHD0V mpgcMRS5V0piKmjkDecr07pizzwqpast5PBF1VQKpIR6zvUGqkuRXEPD4rombsIC/akx kgVmM6g4aFM5pN+t23To5KEbW1CsX7ilIkuKR9yHo4P1lMXYEHu/dxNDAqw0UlScrhMl dt+jrjdi1saaplllyE5tiAYbNd5crOs2+qVMvKdm1I+Fa1OY5EUQ4sJ6VUaHkJDrJlzp pkxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:subject:user-agent:in-reply-to :references:message-id:mime-version:content-transfer-encoding; bh=AWSuzXsUQPN7Oj09z+KYxadDAegLQpa6rfwvkMl0StY=; b=LhRjMWUXt19Vt6jdd1/JRX7+3ncMXyCmMFQDOHEDTeanMx1LS2buG4hk33HjjrzQ4+ yUDD1d+ASE+0rgIatcWrpGtghnlG9MgXNOnZ5duTS0aRXzAVNpbw/seubrbuxO4o+QZQ HMJGB+B9BBbu7EcoWix9A5MeXRdqmwd5/A+txP6ic7Qu6rPFRTP5qTyg0BA8juDpHpVp ocDcIOx9EaXdyk0aGUuKbtl/zJ3As+KjrH7cyWq3DB7kEeysqtEEQ6LxyTXhNTaQgGp+ V4prG8PwTpS8mLP+JZ+DmHMgMz1GvhW4sXvIUQJBuPMSocTLdw2FnUPU0uWrr57YBr/K 1Kfg== X-Gm-Message-State: AOAM530LJgUJLI5kUZsyj7PFwRvhCNa3FABc5y0XtxYE6YrLfX8DZEsK ZtoR+M1O8xMeEUVM01GII/jwWwC6Vco= X-Google-Smtp-Source: ABdhPJwj/XhltFtturMFjBqXLFBtK8MebJ9HaPnT0+893IsCW2/KObgg0212shg2X4f8YjZu51uspg== X-Received: by 2002:a05:6000:2ac:b0:20a:7732:4bb6 with SMTP id l12-20020a05600002ac00b0020a77324bb6mr465033wry.538.1650559206722; Thu, 21 Apr 2022 09:40:06 -0700 (PDT) Received: from [127.0.0.1] ([217.38.59.169]) by smtp.gmail.com with ESMTPSA id z6-20020a1c4c06000000b00392b49c7ad4sm2321277wmf.3.2022.04.21.09.40.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 21 Apr 2022 09:40:05 -0700 (PDT) Date: Thu, 21 Apr 2022 17:40:00 +0100 To: PHP internals User-Agent: K-9 Mail for Android In-Reply-To: <88B1540B-3E99-45E2-87F3-F967D90C691D@cschneid.com> References: <42D0A480-F262-4F72-9C4D-887762A8D800@gmail.com> <0b061f28-a087-efd3-8602-424ee03458e0@gmail.com> <88B1540B-3E99-45E2-87F3-F967D90C691D@cschneid.com> Message-ID: <37E5F0BF-86DC-4E0E-9220-783D0C533E58@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] NULL Coercion Consistency From: rowan.collins@gmail.com (Rowan Tommins) On 21 April 2022 15:40:42 BST, Christian Schneider wrote: >You are leaving out option 3 (which is not part of the RFC but should sti= ll be on the table IMHO): >3) Leave the behavior but change the parameter definition to nullable to = match the implementation=2E Those weren't options, they were questions, or problem statements=2E Also,= as he's repeatedly pointed out, Craig suggested making the parameters expl= icitly nullable, and received clear feedback that that wouldn't be popular= =2E >> For instance, $search =3D ($_GET['q'] ?? ''); is both shorter and clear= er than >> $search =3D ($_GET['q'] ?? NULL); > >Your version is lossy as you cannot distinguish between "empty query" and= "no query was submitted" any longer=2E The example passes the variable to htmlspecialchars, so this is exactly wh= at will happen anyway - it returns an empty string for a null input=2E If y= ou want to distinguish between null and empty string, you *must* avoid pass= ing it to such a function, so the proposed error is a good thing=2E The who= le argument in favour of coercing rests on code that *doesn't* need to dist= inguish between null and empty string=2E Note that as well as being shorter, this is more appropriate than using st= rval() or (string), which will accept other types as well as null=2E Regards, --=20 Rowan Tommins [IMSoP]