Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117212 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89795 invoked from network); 2 Mar 2022 13:38:56 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 2 Mar 2022 13:38:56 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 813FA180553 for ; Wed, 2 Mar 2022 07:00:25 -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,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 ; Wed, 2 Mar 2022 07:00:24 -0800 (PST) Received: by mail-wr1-f54.google.com with SMTP id d3so3260032wrf.1 for ; Wed, 02 Mar 2022 07:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=cmNuiD0YS2RXEq1AGrV+i6LToepWkyxZRcoUGgWM6J0=; b=QSMDFxRqGGbb6O5xMnqltOCzMU70bvwfowEDHgWR4MIpUy2QiiCyUj/uWhZ/COo986 KjKmfgPp16hwCBdp/ykhChn1OWBiJaU0++RwdO7OgfzVOPsqW0Udu2w46P1Hva8AMu47 sw64mUw+APzoF4RyW7QHXOhPn/8B3t7fEYZF4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=cmNuiD0YS2RXEq1AGrV+i6LToepWkyxZRcoUGgWM6J0=; b=VsW5qmqSVdQP7l4fSZFzymklrqd8H9WXZKP/jRa+Ipr79gNmopD9wweaesrCCf01KZ 8BHhlrsUStiA0vzUT8PXH3JLiNQMdbJ4/9ytUVqTPuutpAc5z5BPtexA1kZdQurq6prJ 5hObw9WNM+JZlfPh1bc2t76RtlDDuuUQWM+feQfrSj3KzYxRqGpbT3VkB+FGpMrDmowc K+aryzGddY1VQDCikZoM5fzOX4axjUfR/Y7TWLUx9crsbzEzj28ap+27gd0ZWist5CDn xiKfaJqY2TX+KyjDBvlpL7NQge8PuX5UY6seL3J7YqHocwk7o0j0LFvdsOlp2+FPufwO W1jw== X-Gm-Message-State: AOAM530flhKRMMjL4ryZayMvWMUKuXn58JtI4l3mJM2DQmgoGURhQK5m IPssI+IVcx0bYYSqoFYj8pBeJA== X-Google-Smtp-Source: ABdhPJzPoQtPl2COh37vugTh2ZbOk7lqB+qix0ndJEtgF/2+zrfJTQWEswY2/DpWjdRXiEGZOWDDVw== X-Received: by 2002:a5d:648b:0:b0:1ef:b7c5:897f with SMTP id o11-20020a5d648b000000b001efb7c5897fmr12291858wri.173.1646233223603; Wed, 02 Mar 2022 07:00:23 -0800 (PST) Received: from smtpclient.apple ([94.173.138.98]) by smtp.gmail.com with ESMTPSA id p18-20020adfba92000000b001e4ae791663sm17967098wrg.62.2022.03.02.07.00.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2022 07:00:22 -0800 (PST) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_5E57F328-A4C4-40B6-B618-B2A431AD185F" Mime-Version: 1.0 (Mac OS X Mail 15.0 \(3693.60.0.1.1\)) Date: Wed, 2 Mar 2022 15:00:20 +0000 In-Reply-To: Cc: internals@lists.php.net To: Andreas Leathley References: <983552d8-11f1-b5bc-fb82-148347982fda@gmx.de> <5494eaa7-2fa6-8364-9683-a2c8c9789d81@gmail.com> <69642616-72b7-44fe-97a7-27ae03bc8fce@www.fastmail.com> <7fbed755-42e2-d023-285f-39863a97f297@gmx.de> <3665C848-B4C3-4528-AEFA-02C868748AA8@cschneid.com> <0b5bc29d-3814-0e1d-b94a-47790019c778@gmx.de> <4bff3f23-a3ec-4416-f44e-1f4f5d7e0caa@gmail.com> X-Mailer: Apple Mail (2.3693.60.0.1.1) Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: craig@craigfrancis.co.uk (Craig Francis) --Apple-Mail=_5E57F328-A4C4-40B6-B618-B2A431AD185F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 2 Mar 2022, at 14:39, Andreas Leathley wrote: > Type coercion already often does not work - giving the string "s" to = an > integer-typed argument will lead to a TypeError, it will not be = coerced. > I would prefer less coercions rather than more. Hi Andreas, I'll note that converting from NULL is used all the time, and is well = defined: > https://www.php.net/manual/en/language.types.string.php = > "null is always converted to an empty string." >=20 > https://www.php.net/manual/en/language.types.integer.php = > "null is always converted to zero (0)." >=20 > https://www.php.net/manual/en/language.types.float.php = > "For values of other types, the conversion is performed by converting = the value to int first and then to float" >=20 > https://www.php.net/manual/en/language.types.boolean.php = > "When converting to bool, the following values are considered false = [...] the special type NULL" > [...] but having to coerce null seems always avoidable to me, and null > is a special value explicitely. In my data null and an empty string > sometimes are two possible values, and automatic conversion seems like = a > value judgement by the language that they are kind of similar, which > they should not be. It really depends on your code base... Laravel, Symfony, CakePHP, = CodeIgniter (the frameworks I'm familiar with) all return NULL for = missing GET/POST/COOKIE values, and that is a useful feature... but when = the developer naively passes that to any one of those listed parameters, = you will get a deprecation message in 8.1, and a Type Error in the = future... and finding all of these is incredibly hard. For consistency, the next step should be to deprecate or Type Error when = doing this `setcookie('id', 123)` Craig --Apple-Mail=_5E57F328-A4C4-40B6-B618-B2A431AD185F--