Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116151 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 3446 invoked from network); 23 Sep 2021 20:47:45 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Sep 2021 20:47:45 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 46D82180002 for ; Thu, 23 Sep 2021 14:29:18 -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.1 required=5.0 tests=BAYES_20,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 217.72.192.0/20 X-Spam-Virus: No X-Envelope-From: Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) (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, 23 Sep 2021 14:29:17 -0700 (PDT) Received: from [192.168.178.22] ([85.212.128.151]) by mrelayeu.kundenserver.de (mreue107 [213.165.67.113]) with ESMTPSA (Nemesis) id 1N8X9L-1myKja2E7N-014R0b for ; Thu, 23 Sep 2021 23:29:15 +0200 To: PHP Developers Mailing List References: Message-ID: <50e931e6-a48f-19e8-402e-359fe7dd2a82@nunninger.info> Date: Thu, 23 Sep 2021 23:29:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:2DhdrCu/HZb7vl35x02Q/ISqzuvUb982lBppymtSwgo6qIgPYZr j4GTlW5lRZ4PU4AGaSbZFXxEwJHTq9St3Rdebh9qaoy2ejQHagtUst31V2Ow1ylWh1EEqdh nRaOxylN9IMSz29DWz9VbMawDB/UtzbvqFoPlojmq3nsK5hh2zJeVLy7c94LdUacMJy+w8w m7uWau/7206rcoCTx/R3A== X-UI-Out-Filterresults: notjunk:1;V03:K0:r/Adkoyq5Ag=:4O6+TXdb2coQMN3RZEoKLu vJtkMX7g1DJXeic17UvpD6n6I7VZhi89SG2jexpgd95CtqjxziGLy7J/tlf2Ph16ealT/LeNd I3v4NHbUYNynScab2SiNgyrrlQnnM+Fs7WXbJp3OVuN6bdM5BYyDbRIC0X6zp51IUv211qd+q qVSTsluQO6ijxSIb+zCv5Zxgkx5kl3T4mhl4Mq/ovtmP6UXjYR8HJZcM0OavZ6bWx2iSrsLr8 TAqyNksPbyTRtpnGhD1lwIffrXlN+rXtGJ4Js7iw+EV2YzDl4fzZaMwkcbIv0HDw9TM0oujzA OKz1jfflU9N1AsS0N55BiAxcrFfOUm2ckuPmCEMYEX3eJUViWlRAlm+eZ9xeSJtBE3/idv0bW 1BhzYKIK56RTgfOh0RTZmPbjpB5lMygDNb0X/041kudrIYGXfsOvZrdq4Blh07/dgzMt4xJVR Zy5fewJVSJQReiayu2PhAlAL1/and370cfHnB0evYuV3H+Sp2ZG5k2tzSSp+91H68bhtaZHRu Ptl33kDRRp0xWLs27c43Dj1ILtIniviOL4n49KBdM/fW7E4mNKmQdkubVwd16sCddJfcQJetA XI6W6oFUBCRjvPiJp/u3p+nS3e9Owls9JkduN8eJABwKphG1dz/0DHrmPSb1mRHOKuDqR/3JU g3EbdoWvAl1r6mxepupgt7kmErJ70pee+xvh13B+Yiewh0Ykz6PJg9vs+uZM0Zf7w27Zc5Mhg VjZNBxvjUNMToIQcFM3OQiha5lV8HCYPvlgqXg== Subject: Re: [PHP-DEV] BC breaking changes in PHP 8.1 From: thomas@nunninger.info (Thomas Nunninger) Hi, Am 22.09.21 um 15:29 schrieb Matthew Weier O'Phinney: > 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) !== > $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 — which differs from the previous resource names > in all cases. Would it be helpful if is_resource() raises an error if a resource object is provided as argument instead of returning false? (Should that be limited to the newly introduced resource objects in 8.1? Would a deprecation be enough?) Of course, existing code would not work with that change. But you should be able to spot the error and fix it. It should be possible to write code that works with PHP < 8.1 and >= 8.1. Combined with Rowans idea of a Resource base class or interface that might even be easier? (I assume it's of no additional help to change get_resource_type() to accept resource objects and return the same result as the former, corresponding resource type.) Regards Thomas