Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116992 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43921 invoked from network); 7 Feb 2022 10:51:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Feb 2022 10:51:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0CAD6180088 for ; Mon, 7 Feb 2022 04:07:40 -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,FREEMAIL_FROM,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-yb1-f174.google.com (mail-yb1-f174.google.com [209.85.219.174]) (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:07:36 -0800 (PST) Received: by mail-yb1-f174.google.com with SMTP id e145so19139887yba.12 for ; Mon, 07 Feb 2022 04:07:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LrOyQM1E9OT1JY09hPk8OfmrgWEG6RPSMD38rn2j1vo=; b=VbP6WY1nWohmZBj4sg5wKMP/CgC4s4n+Djwp4AnZSEkFh1m2lh57oYUYW9FaekO5Hv zSYY73699N2Tij+Mh8N/iPMh9cfiOMSiFdhLIyMbJS5PXURljFICumAZjqAmsTltEN6j xw9bQVE8CXlTnWmKX5c8tM/uookrAaHqod6d/AFlPmAmTGVdnyqhEEz2HznOyfAMt5Cw CzZKoM8TWB5hzrbcbyunfakwrlRSJFC/xHRUsnR5KZLnrB6eO2NrL/AcnmztUq5LTzn6 sGWg3VjB2byWTdMRjqZ3Q6VZZiIxEs4bp2/I1AYGYPnjQeLq4kBZ6h7cwz3+UrY0x+vm r59Q== 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=LrOyQM1E9OT1JY09hPk8OfmrgWEG6RPSMD38rn2j1vo=; b=JkhiYZDKOrhh3fLRRjpT9HjUGEWpEEPJWqvqjRAxtaIqdEo8OlDtp8+5gCv/5TBJWZ qwyXLdFLgjcLHSjC2YoS9Yum3sFXVGdI4ODocIAfEoY1hOwmaHX+ZD+HrZVs/iTIdZuk YT6wuLFrOMMhiSwNKcbF745GzND+4A7VsIvHBHLlIPqL/J0EpZpJCUvrh3/rkUf9S0m/ 3j6dWdxTQ9eitX1RA1KY33HsIGTXe90Cl4DTkt5EGGSWweOVMX2jhJwKCCQsWRTspxj7 hPFLwSu5hGgCO0SF/NXeM7jwHIVgUYgLBymLiXOeDMMnuisF4wUhjrrtV+IOmZyb+3G8 U7pg== X-Gm-Message-State: AOAM532waXu7ORr01pZtMV9mXerzEBz2RwhH/Iscika6VLsVm0DrQ3ab 9AiydZqTimYlUP/X//3p6BY7IqCmaGX9VCROynhDrIlACls= X-Google-Smtp-Source: ABdhPJyPCM+fkIlJ35202N4o9+LerSoGyW1W8eCRfoH/498rVU44RUp0vBKvNei6iNUnaZUAbOwwfeAhneQcnmbf9cY= X-Received: by 2002:a5b:6d1:: with SMTP id r17mr7560279ybq.624.1644235655890; Mon, 07 Feb 2022 04:07:35 -0800 (PST) MIME-Version: 1.0 References: <7CCE6061-F5BD-4C10-8BD1-F5A2A994D5F6@cschneid.com> In-Reply-To: <7CCE6061-F5BD-4C10-8BD1-F5A2A994D5F6@cschneid.com> Date: Mon, 7 Feb 2022 12:07:24 +0000 Message-ID: To: Christian Schneider Cc: internals Content-Type: multipart/alternative; boundary="000000000000324ada05d76c72b1" Subject: Re: [PHP-DEV] Allowing NULL for some internal functions From: george.banyard@gmail.com ("G. P. B.") --000000000000324ada05d76c72b1 Content-Type: text/plain; charset="UTF-8" On Mon, 7 Feb 2022 at 09:34, Christian Schneider wrote: > > If a parameter expects a string, that is what it should be given, and > its the callers' responsibility to ensure that is the case. If they fail to > do so then it's an error just like any other. > > The decision to define e.g. strlen() as strlen(string $string) instead of > strlen(?string $string) was arbitrary and I for one would prefer the loose > definition. > > - Chris > I'm not sure what you are getting on here? strlen() was always defined to only take a string and never was nullable in the first place. The RFC which is at the heart of this is the one to make internal functions and userland functions consistent. Therefore introducing a mechanism which makes only *some* functions special and weird is a complete no go for me. Either there is a (strong) case for the parameter to be nullable, and then it should be marked as such and not do weird shenanigans with regards to strict_types (which I dislike more and more by the second), or there is not. 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. Let's look at an example taken from the document ( https://github.com/craigfrancis/php-allow-null-rfc/blob/main/functions-change.md#output ) - setcookie(name:string, *value:string*, expires_or_options:array|int, *path:string*, *domain:string*, secure:bool, httponly:bool) - setrawcookie(name:string, *value:string*, expires_or_options:array|int, *path:string*, *domain:string*, secure:bool, httponly:bool) I really do not see why for the path and the domain should *ever* accept NULL, as if somehow that happens I would have some serious questions about how you get that information. However, there *might* be an argument to be made to make the value parameter nullable. Although I would find this instance very questionable. I'm not against in principle of marking certain parameters as nullable, but it for sure should not be on a basis of using strict_types or not. Best regards, George P. Banyard --000000000000324ada05d76c72b1--