Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116127 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 43691 invoked from network); 22 Sep 2021 12:48:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Sep 2021 12:48:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0CBD91804B2 for ; Wed, 22 Sep 2021 06:29:59 -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=-2.1 required=5.0 tests=BAYES_00,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-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (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, 22 Sep 2021 06:29:58 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id x27so11980435lfu.5 for ; Wed, 22 Sep 2021 06:29:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=jMpNUqD9eqCBL+yBw+nKdpDzhTdYgMHOgv50aXkqsCs=; b=c4fusiVN0sPsGwkhgEjiIg2alwqxYf2oRGMupK8rChT9SrUEPN+d1DpLZjzMn8oOcU ysekjJCkziuAflAiqZNIQelp7qOOyj2er1xq0sZvEvgtuoi48IGYhRM/NKnfDjnqIZqa KzxE/aSzK1wlKKWryAJZCpG0v28UqKwyveda97eUVaaZ6GF39tCTFUbm2R3deSaZwYbQ h3DH1MEuvYiMyjKuItSwMexdn80rtSwj0gPS2g/GpiSU0Iroz5xPXnWDz3ErlQvG46wq 0/KXP2zBFh+cprjx20w4kzr5I9EDJN0Jl8a8QmqLxZY7EBt6/SKghAzDSVkmA3wuWa3W UBjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=jMpNUqD9eqCBL+yBw+nKdpDzhTdYgMHOgv50aXkqsCs=; b=kMq9vjBTBlDjTiBU8OaHcN1iCBpJXbUdFfAxZPPWk4tuG7WZTx4sanS1RVE3pGYHQu wo3Ouahic7biFvPN/qy4QHmvHAh3umGWmIGJVvfaA+3qi7GcuJDeYE9M4z0bKuIOjcDw S9jeRQzpVfLe3uR2ZiKl1BZxENkNpTHNsVjawsWm8M+kjs6Auppn032BIGvBloUIoMSY TdORk6SWeAMZuSsgqAC9ZmlVBVMx9B1vCj2V73jZd+khHzkJTEeTEC2RL1QuUvXEvVAw Xn8dI3XE3lCuT5UqncyA0ApbavllDqy/k8rW3u9gDSM2U1C24FnAXWKCIum11jPkGPIK +OQw== X-Gm-Message-State: AOAM531fDm8djtWS4KcyttpGQfV5iJUSbzSilIXZ2YjsNzm0rM7c8KbJ gBpD+3ncFAXKlnDFYmHjPtKwK2UflMtIYOWz5lZ88GsbLqA= X-Google-Smtp-Source: ABdhPJzQstPgh4P42y9F4B44DP5ugDzPJ0vnpzAiSdD0f7CIMRjvaUN9XNBSVomkL+tX1I9sEOGf4ULAI6SoDbVJmKE= X-Received: by 2002:a05:6512:3047:: with SMTP id b7mr28564372lfb.386.1632317380382; Wed, 22 Sep 2021 06:29:40 -0700 (PDT) MIME-Version: 1.0 Date: Wed, 22 Sep 2021 08:29:28 -0500 Message-ID: To: PHP Developers Mailing List Content-Type: multipart/alternative; boundary="0000000000009e539f05cc958170" Subject: BC breaking changes in PHP 8.1 From: mweierophinney@gmail.com ("Matthew Weier O'Phinney") --0000000000009e539f05cc958170 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yesterday, I opened an issue regarding a change in the pgsql extension ( https://bugs.php.net/bug.php?id=3D81464). PHP 8.0 introduced the concept of "resource objects". Where previously we would have resources, and use `get_resource_type()` when we needed to differentiate various resources, resource objects give us immutable objects instead that allow us to type hint. Personally, I think this is wonderful! The rollout for 8.0 was incomplete, however, and only touched on something like 4-6 different resource types. Still, a good start. With PHP 8.1, we're seeing the addition of more of these, and it was encountering one of those changes that prompted the bug I previously linked to. Here's the issue: while overall, I like the move to resource objects, introducing them in a MINOR release is hugely problematic. Previously, you would do constructs such as the following: if (! is_resource($resource) || get_resource_type($resource) !=3D=3D $someSpecificType) { // skip a test or raise an exception } Resource objects, however: - Return `false` for `is_resource()` checks. - Raise a warning for `get_resource_type()` checks, and/or report the resource object class name =E2=80=94 which differs from the previous resour= ce names in all cases. This means conditionals like the above BREAK. As a concrete example, I did PHP 8.1 updates for laminas-db last week, and assumed our postgres integration tests were running when we finally had all tests passing successfully. However, what was really happening was that our test suite was testing with `is_resource()` and skipping tests if resources were not present. We shipped with broken pgsql support as a result, and it wasn't until test suites in other components started failing that we were able to identify the issue. Further, the "fix" so that the code would work on both 8.1 AND versions prior to 8.1 meant complicating the conditional, adding a `! $resource instanceof \PgSql\Connection` into the mix. The code gets unwieldy very quickly, and having to do this to support a new minor version was irritating. When I opened the aforementioned bug report, it was immediately closed as "not an issue" with the explanation that it was "documented in UPGRADING". This is not an acceptable explanation. - There was no RFC related to 8.1 indicating these changes were happening. (In fact, there was no RFC for resource objects in the first place =E2=80= =94 which is concerning considering the BC implications!) - In semantic versioning, existing APIs MUST NOT change in a new minor version, only in new major versions. Reading the UPGRADING guide, there's a HUGE section of backwards incompatible changes for 8.1 =E2=80=94 THIRTY-FOUR of them. Nested in these= are notes of around a half-dozen extensions that once produced resources now producing resource objects. The pace of change in PHP is already breathtaking when you consider large projects (both OSS and in userland); keeping up with new features is in and of itself quite a challenge. Introducing BC breaks in minor versions makes things harder for everyone, as now you have to figure out not only if there's new features you want to adopt, but whether or not there are changes that will actively break your existing code. I strongly feel that anything in the backwards incompatible section of the UPGRADING guide should be deferred to 9.0, when people actually expect things to change. --=20 Matthew Weier O'Phinney mweierophinney@gmail.com https://mwop.net/ he/him --0000000000009e539f05cc958170--