Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116155 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 25284 invoked from network); 25 Sep 2021 10:43:01 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Sep 2021 10:43:01 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 205871804CF for ; Sat, 25 Sep 2021 04:24:58 -0700 (PDT) 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: No X-Envelope-From: Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 ; Sat, 25 Sep 2021 04:24:57 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id z24so52787498lfu.13 for ; Sat, 25 Sep 2021 04:24:57 -0700 (PDT) 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=PHgvaMZ2QrtusqRGtE/7a8+vO+eCz90uqgZ6Kc5fzSA=; b=cJIq8FmRvGu0tpNdb7taHLeB/7PqJRJFw/m9zrGCWq0u+NRZqNR8nlRvdNMMDiRBTg wHJ2qWrtzwTlnfjWwEXmXHB0VTS8SXpLWN2l4JWmDx1YHTApK/LbrvISc+AM8CVI6BVK HJYGkB21c3z9P/m0NEIMUJXEG9A4tPa4V8Qhg= 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=PHgvaMZ2QrtusqRGtE/7a8+vO+eCz90uqgZ6Kc5fzSA=; b=UHwbamBHOYAfwN2Zd51Ujhgt92kuti3bYAGB4biiRzdIsjxGXztdnWmqETo/yZ2ywP iZHGhKlQpAk2FYDYb+GYf6+4V9Xfhqj1mVxlSiWUVXcFLBmJpn38acwWk7EqtfDhfnj8 bgqwMUFLTKBE8Q7mjTzNZDi2ZL3NLHVW8B36WXOnGOvk+PqQXF0vZ+nUiViOvDxpVCnS iW4Emdf51XExWbpG+Ss+Ni+B8cp4/aU+gsUKlpm/X6g9wjrGbfJQfoncgyAgcDjxLAXD Sid4/7ZS0eWKD5xmCLCKSBGDLqV2kO7yWhpps0Kg6H7RiekymbnwihCKgtFtmMW8fhLX v+NA== X-Gm-Message-State: AOAM532Adayx3gUPh4DqR07fmdLgsShAW2zWIEEgDuW4pM/UsxU80okS g8rphgNa1FETl1/p1Kd6CLspbdl+GIG1QuKiWSYG0g== X-Google-Smtp-Source: ABdhPJyEOWNUem/0wvrW2sIUJqAydtSofi4xVP30P9IV85t1kReYk2Bgj5dHRBdfHC1rD9fM3MSeciINxvzupa4JuNk= X-Received: by 2002:a2e:9d08:: with SMTP id t8mr11667878lji.212.1632569093655; Sat, 25 Sep 2021 04:24:53 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 25 Sep 2021 12:24:40 +0100 Message-ID: To: Nikita Popov Cc: "Matthew Weier O'Phinney" , PHP Developers Mailing List Content-Type: multipart/alternative; boundary="000000000000e620f805ccd01c1e" Subject: Re: [PHP-DEV] BC breaking changes in PHP 8.1 From: craig@craigfrancis.co.uk (Craig Francis) --000000000000e620f805ccd01c1e Content-Type: text/plain; charset="UTF-8" On Thu, 23 Sept 2021 at 17:53, Nikita Popov wrote: > I believe the changes in PHP 8.1 with the highest migration burden for > open-source libraries are the additional of tentative return types (aka > "put #[ReturnTypeWillChange] everywhere") and deprecation of null arguments > to internal functions, followed by the float to int precision-loss > deprecation and, depending on project, the Serializable deprecation. > > [...] > > I'm not sure what we can do about that though. Sure, we could stop with the > (runtime) deprecations, only document the change and then directly > implement it at the next major version. That would be much simpler for us > (generating runtime deprecations is actually a major implementation pain, > as well as a big performance concern) and would make minor version upgrades > for libraries much simpler. However, it also removes the ability to address > problems before they turn into fatal errors, e.g. by recording any stray > deprecation warnings in production. > While "put #[ReturnTypeWillChange] everywhere" has been fairly easy... "deprecation of null arguments to internal functions" is a major issue, because they are everywhere, and only really found at run-time... and tbh, I can't explain to anyone why it's so important this will be broken in the future, especially for the majority of projects who are not using `strict_types=1`. Don't get me wrong, a user/library defined function that says it only wants a string, I get that, but they have full control over it (for their projects) so they can be as strict as they like, or use `?string`... but the internals functions have always accepted NULL, and used by everyone. As I noted last week, frameworks use NULL for undefined GET/POST/COOKIE values, so these NULL get everywhere; and it can be useful to distinguish between a value that wasn't set vs an empty string (e.g. when saving to a database, a NULL can be "do not change", which is different to "set this field to an empty string"). One of the projects I work with have gone down the route of "check it, but you should probably stick `strval()` in every case of `strlen()`, `trim()`, `strpos()`, `htmlspecialchars()`, `strtoupper()`, `hash()`, `hash_equals()`, `simplexml_load_string()`, `strtotime()`, `explode()`, etc"... which really doesn't seem sensible (one commit was over 200 manually checked/changed lines, and took about 3 days)... the other projects have gone with the "we can stick on 8.0 for a while, hopefully things change". Maybe PHP 8.1 could be updated so these string functions could continue accepting NULL? Craig --000000000000e620f805ccd01c1e--