Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116995 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50448 invoked from network); 7 Feb 2022 11:24:10 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2022 11:24:10 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D353B1804C4 for ; Mon, 7 Feb 2022 04:39:52 -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: No X-Envelope-From: Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (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 ; Mon, 7 Feb 2022 04:39:52 -0800 (PST) Received: by mail-lj1-f178.google.com with SMTP id bx31so19435527ljb.0 for ; Mon, 07 Feb 2022 04:39:52 -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=3iuO4C561tQaNY6+0MvVMHVb3rcbGxXr8L8aw4x8sN4=; b=QdLTKmDNp4NaBT+W4sVK9krlptfEQYU2IXRJgJJRIZMlCxv1vRzOcvNc82yMTFOyDu XYC77ao0DY6nOj+DaBb2ZLttBPU4GVgdBDp90YlxuYqBEGMjY2BxeCzBikGTtrDG/Dtl a5oChMh/1TiTxfRdmCMl+Nj689g47KANGHvXo= 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=3iuO4C561tQaNY6+0MvVMHVb3rcbGxXr8L8aw4x8sN4=; b=JIQ5Nb4YwRfqZkb55HGH/wUX/k+oFsAzuH4eMif3XEDoZT6dHNoROFvooI+iyrz/mU sN8ZOXXKv/7LBq57JBnjUjGGOddBGnfLBRdwMt8meD9RE8nkBjwsJpUcXGUbfeq3mOV5 NlmIXJAWDljP38jgPaqKYi6WAgCb5m2g/m8DhJ8nr1JkG5XQ4g6XLTLeLct44wti7kfE x07D76eELCB2DxaGuIjBiu4AvcB0E3RznJBfe2109BlNoixDK9m16kisEV/spvvOciAv pVTCPZkCsxh+UmSvYby7/QC7ncvyHL+qQqnukRL49osyM9P0uY1R+xJoORgTuCif1eBI cHuA== X-Gm-Message-State: AOAM530Ss2u3RXPcJPA0JeLhnvJUxxdoYdt4EHS7KQSQarhVKebi0SzK tc4S9tiWfAyT6ijSY8Rvdi4lSwR9+U6IGSArFTjgxA== X-Google-Smtp-Source: ABdhPJxj+DsduHiWdq6GseY8XJ+Mpm3FV8qK/VD0hADzY5HbQWaZ7g5lBbcBGJMDAYWpGuCQiph5s8Y3MIW/Oh+c01s= X-Received: by 2002:a2e:5717:: with SMTP id l23mr8378620ljb.495.1644237589888; Mon, 07 Feb 2022 04:39:49 -0800 (PST) MIME-Version: 1.0 References: <7CCE6061-F5BD-4C10-8BD1-F5A2A994D5F6@cschneid.com> In-Reply-To: Date: Mon, 7 Feb 2022 12:39:38 +0000 Message-ID: To: "G. P. B." Cc: Christian Schneider , internals Content-Type: multipart/alternative; boundary="00000000000078dccb05d76ce5a6" Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: craig@craigfrancis.co.uk (Craig Francis) --00000000000078dccb05d76ce5a6 Content-Type: text/plain; charset="UTF-8" On Mon, 7 Feb 2022 at 12:07, G. P. B. wrote: > The list of proposed functions is also excessive and just feels that any > function which raised a diagnostic during a test run on 8.1 was chugged > into it. > Not really, while I did create a throw-away script that used `get_defined_functions()` and `ReflectionFunction` to find all function arguments that accepted strings, and not `->allowsNull()`... I manually checked every single one, and I considered if passing NULL to that argument could represent a problem that warrants a Fatal Error for *everyone*. https://github.com/craigfrancis/php-allow-null-rfc/blob/main/functions.php This is why I have 2 other lists which I don't think justify any changes; e.g. it's almost certainly wrong to pass `NULL` to the `$characters` argument in `trim()`: https://github.com/craigfrancis/php-allow-null-rfc/blob/main/functions-maybe.md https://github.com/craigfrancis/php-allow-null-rfc/blob/main/functions-other.md I'd argue that the length of the list represents the size of the problem (i.e. the amount of changes developers will need to make for PHP 9)... for example... - setcookie > - setrawcookie > > I really do not see why for the path and the domain should *ever* accept > NULL. Developers will often use NULL for argument defaults (remember, we didn't show that the default was an empty string in the documentation, just that it was an optional argument)... and considering the output for these two functions, I see it as pretty reasonable that NULL was used as a way to say "do not set the path attribute". setcookie('name', 'value', 0, '/', '', true); // set-cookie: a=a; path=/; secure setcookie('name', 'value', 0, '', '', true); // set-cookie: a=a; secure setcookie('name', 'value', 0, NULL, '', true); // set-cookie: a=a; secure So back to the same question as before, why should this NULL in the last line result in a Fatal Error for everyone who does this in PHP 9? Craig --00000000000078dccb05d76ce5a6--