Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:117238 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72253 invoked from network); 3 Mar 2022 09:35:00 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Mar 2022 09:35:00 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD41718053B for ; Thu, 3 Mar 2022 02:56:41 -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=-0.7 required=5.0 tests=BAYES_05,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-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (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, 3 Mar 2022 02:56:41 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id o6so6241411ljp.3 for ; Thu, 03 Mar 2022 02:56:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=craigfrancis.co.uk; s=default; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=88HQkEYJnkUb0g+WfjB0tjX1Ln6cuslckntHSJC1S4s=; b=C1yAw8lxpV958n4PiGyBsBFeDfhfMQrjmLpzxVFAfoQaxvEeaoINJ50aoIFQyik4b+ X6WYY3gmfrXvB/RVl1EIaklkrjriQ1q9eIe+2YKPUYknSNhhsMdDl8TIQ03Dhrum3EsS SNygVcIr9L998BvOObzxJ8Ow6oqNMVTNRep38= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=88HQkEYJnkUb0g+WfjB0tjX1Ln6cuslckntHSJC1S4s=; b=w4amAhHgK8/inVJ7cSvKn+WfFZ1pTLCclJ8+aKBjLTOcd6G/h50Nw7Lm0ojA6+3zdf 2XxNzKOPY/HdgHGeBmhdGoP9dASuBwgKO5IFNCx1cNLAEmkv1JzPjyepdqoiiV7WkZhR t5Vi8HmaHDOlhdXahfBIQY2ThmNhhIcLXEj8nicRpb3+UlSGV8/hxbDTWyRsAxjn4OY3 /tBjVEQdxZjk173lGgzWR5GWHA68oLnnJ1Urby8kNH7ZaTHrPPgEYNLlZrrep+Yo4tlO WDWabond6+bFlD+FHuQUyKYH5HkYcXPejsBjEO83PlTmrA7aCtrP8GpihBR2WI4jhMIv AtsQ== X-Gm-Message-State: AOAM533PjOpl9k9ut3KOc3paZIFcA+VS+WBzRNToarX/sDSbQWUZPYLS GJLtzORHtEs5H/yNEcJMMbPQpGMDg4k6MRKAE2ns6w== X-Google-Smtp-Source: ABdhPJw6+1RpoGXUyewr69jBnuIa4xp0cAINM641CzHrH1Hc2tlcs9SlakTdDlsE6iCrrXeYN0nXR1t1kFKxcLSo2tc= X-Received: by 2002:a2e:8198:0:b0:246:e7d:45d2 with SMTP id e24-20020a2e8198000000b002460e7d45d2mr22974252ljg.495.1646304999539; Thu, 03 Mar 2022 02:56:39 -0800 (PST) MIME-Version: 1.0 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> <2d06bc12-7d7e-4a88-b823-de64642381e6@www.fastmail.com> In-Reply-To: Date: Thu, 3 Mar 2022 10:56:28 +0000 Message-ID: To: =?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000b0962c05d94e40a6" Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: craig@craigfrancis.co.uk (Craig Francis) --000000000000b0962c05d94e40a6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, 2 Mar 2022 at 21:42, Alexandru P=C4=83tr=C4=83nescu wrote: > What bothers me a bit is why should strlen(false) be a valid method call > but strlen(null) not so much. I think this is the inconsistency that shou= ld > be fixed so the language would be easier to work with. > Hi Alexandru, I typically spend an hour carefully thinking about each email I send, both on and off list. I read and re-read what each person said, I try to understand why they are saying it, my replies / suggestions are me trying to find the best solution that will work for as many people as possible, and the consequences they would have. I do not consider my coding style to be only one, and I would never simply force someone to work in a different way, in the same way that I won't force a CSP scrpt-src that blocked 'unsafe-inline' on everyone no matter how many XSS vulnerabilities it would solve (I highlight provable problems, I make suggestions on how to fix, and I'm open to alternative ideas). With this RFC, I made my original suggestion, which was to alter some functions so they could continue to accept NULL. I was wrong with that approach (first I suggested doing this silently, which Larry correctly pointed out was too messy; then I considered Larry's idea of updating function signatures, but there are too many, and would reduce some useful checks for those using `strict_types`). The solution I have been proposing for the last week or so is based on making PHP work with the well documented and understood coercion behaviour for null, in a way that keeps with the spirit of the original RFC, and is how many PHP scripts work today (noting that your typical PHP developer does not dare enter the Internals mailing list). I respect your idea, but what you are suggesting is very messy, it seems to randomly deprecate and remove some type coercions, but that is just going to confuse developers, and make upgrading harder to 9.0 even harder than what is currently planned (see Python 2 to 3 as a classic example). I know some people here fantasise of forcing everyone to use `strict_types`, and making everyone use static analysis tools, but we are a long way off from that happening today... what we can do - make it easy to move to `strict_types` (ideally with good tooling), to sell that approach with the positives it brings, while also keeping non-`strict_types` working as expected so people continue to upgrade. Craig --000000000000b0962c05d94e40a6--