Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119216 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10148 invoked from network); 30 Dec 2022 17:36:43 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Dec 2022 17:36:43 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9D46218033A for ; Fri, 30 Dec 2022 09:36:42 -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,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 30 Dec 2022 09:36:42 -0800 (PST) Received: by mail-pg1-f170.google.com with SMTP id h192so9754152pgc.7 for ; Fri, 30 Dec 2022 09:36:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=zu3BNJKjLq5QJNFwaJGzuQr7H4HvEMjlBgG25r4rDdY=; b=Sz6X7z+V1c8Gqsbk6qOIihGvJUhnfY7TvscSEsMH6otsWSclasprq16+zUy69Vo5Lr 0UiASRJBNwpDJPl6YmyGf3noNFgb1FqUyWRXdUwXH1gYd5b7UgNfG6htrYhwktDF5SV/ 6LX8J+fnAFOEBA8DJhQyuRHI7SxoEPGh1UXX0ng52JeQiMQXPOuxOa6JCuPXO5MhJbER wrNJGTXsyj+OP/92tqJKjRmYWaIxsCwemdFpJXDunKdlK3txzwB9aP/IeGJ+i2mkq6O+ iHVZ92wWgjDyWeUfShB944x0YVSZ2/ped3Vg00z9BOp4hq+33uiNWeNwzLl+iaUkNAnn jOIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zu3BNJKjLq5QJNFwaJGzuQr7H4HvEMjlBgG25r4rDdY=; b=UgkJepXTVZQOxFoaIUiQ4OxMKl0B/4cKNO5P0inTxVJqxUYYgKlaCSuGGU9RZXWaF0 zjOETK70KQAzgX4fHHMLw5UI2rOEDW7ycqub5KuRU+G5Ik4Kl1CvU9xOw6K/7a3unC45 Azd1maMNJe/eNHNn+I6nrBMD4lZudje3TB9TlJKZKR0LqdPyE6HGlz1YtB1R0OC4ViWa EgeuLPO6E63nOrwt0dqVPMjFFlkVKyt2hhModSRFzIca66+cnondg80JUucqkh57aM/U 0sQwds/A1q9DYKP2y1LsXnZrO9vuW5VEG0koeMat4nyIXATSPSp9Vqm2ULoEhqgp8w7A TNGA== X-Gm-Message-State: AFqh2krvYYQZqDehPe5qKI+OyNJk0zbvldUXRiLtHKhUpt7kbK5R7X+a FQq9m2tIF8/RBtlBag4s2q3aSxeBnrPahsn9QALOMq0g9zTlYQ== X-Google-Smtp-Source: AMrXdXtyu4NH4vdvV0xS15UPknKtYMLmDYz9X26pNwH9a4y0/ct/suWYbMS1cGeeeb3/xWjfYv6iWogVBE0mnmIE81o= X-Received: by 2002:a63:fe06:0:b0:492:23d5:1e3a with SMTP id p6-20020a63fe06000000b0049223d51e3amr1856846pgh.386.1672421800691; Fri, 30 Dec 2022 09:36:40 -0800 (PST) MIME-Version: 1.0 Date: Fri, 30 Dec 2022 17:36:29 +0000 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="000000000000584b8105f10f0b61" Subject: [PHP-DEV] What to do with opaque GMP objects which allows instantiation From: george.banyard@gmail.com ("G. P. B.") --000000000000584b8105f10f0b61 Content-Type: text/plain; charset="UTF-8" Hello internals, While working on something, I was using GMP for a test case and creating it by doing akin to $o = new GMP(5); However, this does *not* create a GMP object initialized to 5, rather it creates and sets the value to 0. This is because it does not define a constructor, and the proper way to create GMP objects is to use the procedural gmp_init() API. GMP was one of the first resource to object conversions which was performed in PHP 5.6. More recent resource to object conversions prevent the instantiation of the opaque object via new by defining a constructor that throws an Error to point to the procedural API. (something which would have saved me at least 30 minutes of debug time) Opened an issue [1] and a PR was made [2] which I requested to target 8.1 as I was considering this a bugfix, however it seems that some people to initialize the object by just writing new GMP(). Thus, the question, what should we do? - Merge as a bug fix for 8.1. - Target master (or 8.2.1) and align the behaviour with other opaque objects. - Add a proper constructor that does the same as gmp_init() in master/8.2.1 - Add a mock constructor that allows instantiating without arguments, but throws an error if trying to provide an argument. - Do nothing Best regards, George P. Banyard [1] https://github.com/php/php-src/issues/10155 [2] https://github.com/php/php-src/pull/10158 --000000000000584b8105f10f0b61--