Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121643 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 32494 invoked from network); 10 Nov 2023 13:35:02 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 10 Nov 2023 13:35:02 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0592F1804D0 for ; Fri, 10 Nov 2023 05:35:02 -0800 (PST) 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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, 10 Nov 2023 05:35:01 -0800 (PST) Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-589d412e8aeso1076339eaf.3 for ; Fri, 10 Nov 2023 05:35:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699623301; x=1700228101; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q31IGBmI7bvSdptou4SeImHv8LG1KtIdopGm85EZpag=; b=fnDHcx878wNtezKnd3yF+CpyCOTXa2aCCyrQdVwmDaH3VOQgLMAiwj52WBQf1Nifpx VO3ieyu3cdHGsVUM2yeiGNlTHmhpJG0NfJMN4GBTxx40DcxSG9F0onswQAoNReDDu+3D zKqHfxjxraPesS1AOXE9H3FwPMAEWwqRkpJW+fE7EO6RwgMMTRLtvC9snqzoxjxJvZou USS7Qzf6JY4CjbDYjlaRbGWNqVPoAPJ0co7JI9v9hj2GjeuLzBAlSD70CxowoDDvA+TJ UwpVjGCaJH75+wijTMP+SW3FYx+MKXeZw/d/K6sbV0DQZpdRu5A6RBDNFs1IvDhIFlEz /IGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699623301; x=1700228101; h=content-transfer-encoding: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=Q31IGBmI7bvSdptou4SeImHv8LG1KtIdopGm85EZpag=; b=Y+vR+Nx6twHNNERqv+sp3Ui/FAFYK48d7Qf3/8m04NdHh8u1gU9qmK2PUotP00D0uh QrWhIA/BAmkSjM8KTQNEwgn/rGAs44ICtHwaFMSyYrnEQkExe6OZ5iOAfMrfJtV2aPdf Xsy0Vhn46Zv3v62f2ss9HGT50Bhzm/SZP4ByBpB0KugoBgRr6eSJkcwXDSuRQegKw2kg dT/7VeGGQP9us2ZA0kSH7olMuf3to4WC+L+iB9ojsnj1ZccDzhfRw3pGGVS1YWp3e7M1 GP2QzGpdmFZCCcaAJMjLDQm6zyEHS4oLD7ryAhpGLRmmL9iBDIa/vE33q26WDfFgR+T5 S+vA== X-Gm-Message-State: AOJu0YypwAYaOVhTT9qJ6DtWxG4Nfy7mEU8/fC9rNZX2/5cfXZCScCgG 6G3blcxgyxXY0jUg3hq7NAqglRrh4SrSqji95AY= X-Google-Smtp-Source: AGHT+IHf24t5ylRng83x1FFJuiPdClOluiur96P+2eAPkMs5Zk0czjeHLKDV4h6rU3oA7WSKoFt9KuMrNCM48yMK4qs= X-Received: by 2002:a4a:df15:0:b0:57b:8ff1:f482 with SMTP id i21-20020a4adf15000000b0057b8ff1f482mr7772108oou.0.1699623300763; Fri, 10 Nov 2023 05:35:00 -0800 (PST) MIME-Version: 1.0 References: <5144806E-E21F-4AF8-B9A2-0161561A6B9E@craigfrancis.co.uk> <1A044D32-019A-4152-A3C0-3F393974AC3B@craigfrancis.co.uk> <88815C70-1100-442A-AFCC-A420862669C3@craigfrancis.co.uk> <6049A048-1B2B-4DD8-B2DD-05F7CFBB8EE6@craigfrancis.co.uk> In-Reply-To: <6049A048-1B2B-4DD8-B2DD-05F7CFBB8EE6@craigfrancis.co.uk> Date: Fri, 10 Nov 2023 14:34:49 +0100 Message-ID: To: Craig Francis Cc: Andreas Leathley , internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Passing null to parameter From: landers.robert@gmail.com (Robert Landers) On Fri, Nov 10, 2023 at 1:33=E2=80=AFPM Craig Francis wrote: > > On 10 Nov 2023, at 12:16, Andreas Leathley wrote: > > Also note that in your example $q could be an array (leading to a fatal= error in the code)from the request data, which is why checking types thoro= ughly (not just coercing them with strval) can be helpful in avoiding unexp= ected situations and deciding how to handle such situations, instead of yol= o-ing it. > > Yep, and I completely agree, but I'm not focusing on my code, I'm looking= at the code the vast majority of developers write... and I do not want PHP= 9 to be so difficult to use that people stay on PHP 8 forever. > > Craig > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Personally, I find the whole strict types + nullable thing really bad. (string) null is "", which is hopefully pretty well known. But with strict types, you may not even know you have a null value because casting is used all over the code base. I constantly have to point out this in code reviews and suggest this: // val is an int|string|null func((string) ($val ?? throw new LogicException("val should not be null")))= ; which just feels dirty. At least in non-strict type mode, we would get "null catching" for free (at the expense of deterministic coercion), and is one reason we're actually considering to switch back to non-strict types; a very simple coercion system for everything but null. So, really, I think it might be a good idea to rethink the whole type system at some point. There isn't really any ideal solution atm for handling nulls + strict types. Robert Landers Software Engineer Utrecht NL