Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117809 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 17655 invoked from network); 28 May 2022 00:52:44 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 28 May 2022 00:52:44 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 343C3180539 for ; Fri, 27 May 2022 19:35:53 -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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 27 May 2022 19:35:52 -0700 (PDT) Received: by mail-wr1-f45.google.com with SMTP id t13so7945423wrg.9 for ; Fri, 27 May 2022 19:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mEFp8j+mOSiuulC5yOg0IBkvGm6WLpku+zNB+cY88eo=; b=DKAZxW0OrhuY4MGBFDZQLDz/cflC6pi/ctLtA6/iuaZun+t4arUDrIQhd+MtspNqt+ uTP10i8A11lZv7Wp5/UYGYBSh/qyDB/SLZwjxFUIPzFR3GmwLrL3he/F8wRLTg+WYL/B REhfwKYm7m8dXxSh5+N7WJolTaPWFDvibOlFs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mEFp8j+mOSiuulC5yOg0IBkvGm6WLpku+zNB+cY88eo=; b=2t9ZkJw26+NP2SJVDowkWLBprPDxD4tGzNeK9T5i0nHzUrlQbyooyTJ4EqkOCwEHgF G7FCYFzv/qVnYsEDIAz7g8PYKkCtFih1+o/j/eInijFubdA9FsbkSJNv+32ovxUeZ5JI P+UCO1Y8iLWH6o/YfbntQKOzOd90QBCgB8ONLKUCJ5IciENHspZVquZ03zn965DMlCIR VAZO9sxttbAazwvUmaNxG5C4CF6LfR+FTfO0WE8u/DM+OnaPK6UUmhuOOvzvr60WH9iH d8W6M069TdFSzB/KRvLAtgG5glIgdZPBIAwyuJ8BTMpTiwr89+M5O3HI9mcPoBKEpqhu DCGQ== X-Gm-Message-State: AOAM531JjZpjNgfCESLbigpfQX/NN3eH5G8vRjqWV80MF+8YD7z8W+7D wmga0duA/FORm5YJhAlOnq6fag== X-Google-Smtp-Source: ABdhPJwwuU7PVAWXMvceeL7DQbJgEKrKNFd6wlP42b0NxOynQLJGEkW4VR7yAO5AqZq3WdlRAIsW3g== X-Received: by 2002:a5d:6644:0:b0:20f:ca28:2845 with SMTP id f4-20020a5d6644000000b0020fca282845mr26817249wrw.525.1653705351644; Fri, 27 May 2022 19:35:51 -0700 (PDT) Received: from smtpclient.apple ([94.173.138.98]) by smtp.gmail.com with ESMTPSA id bw30-20020a0560001f9e00b0020ffa2799f4sm2860694wrb.73.2022.05.27.19.35.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 May 2022 19:35:50 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) In-Reply-To: Date: Sat, 28 May 2022 03:35:50 +0100 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: <1755E8B5-229B-47B2-BBAF-B5E014F5473D@craigfrancis.co.uk> <1180af01-080f-ee0a-3159-74bf7e0a8aea@gmail.com> <73F563E2-7C31-4B5E-A6B9-AE1BD05ADD1C@craigfrancis.co.uk> To: Jordan LeDoux X-Mailer: Apple Mail (2.3696.100.31) Subject: Re: [PHP-DEV] NULL Coercion Consistency From: craig@craigfrancis.co.uk (Craig Francis) On 27 May 2022, at 07:44, Jordan LeDoux wrote: > On Thu, May 26, 2022 at 5:21 AM Craig Francis = wrote: >> It sounds like you got lucky - you have a function that has a problem = with NULL (but I assume it's fine with an empty string?), and during = your testing you happened to pass NULL to this function. As noted = before, static analysis is *considerably* better at these types of = checks, because it's able check if variables *can* contain NULL. They = can also perform other checks as well (important when your code seems to = care about NULL vs an empty string). >=20 >=20 > Nearly *all* code has a problem with null. Erm, but it doesn't... does it? I know I keep going on about this very simply example, but it represents = a fairly typical style of programming PHP, and I just do not understand = what the problem with it is: ``` $search =3D $request->input('q'); // Laravel, returns NULL when 'q' is = not defined. echo 'Results for ' . htmlspecialchars($search); ``` But forget about it, hopefully someone else can find a solution to the = problem. On 27 May 2022, at 07:44, Jordan LeDoux wrote: > It very much feels like the original effort to deprecate null calls = decided to resolve this by saying "let's have the language help = developers improve their code so it doesn't have these problems in the = first place", and this effort is trying to resolve this by saying "let's = have the language support the buggy code in ways that makes it work". >=20 > At my job, my task for the last three weeks has literally been = upgrading our internal codebase for 8.1, and the biggest set of logs I'm = dealing with is exactly what you're talking about here: null's passed to = internal functions. Every single case I've looked at so far has been = traced to code that was written incorrectly, where some code somewhere = was not properly guarding its values, and error cases were slipping = through. For one of the teams I work with (the only one trying to make the = relevant changes), this is also their "biggest" problem... but they are = having exactly the opposite experience, a considerable amount of hours = have gone into finding and changing their code, and not a single change = was for code that was "written incorrectly" (I suppose that depends on = what you think "correct" code is)... the other teams I work with are = either suppressing this notice, or simply not upgrading to 8.1. Craig