Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112905 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41638 invoked from network); 15 Jan 2021 18:01:38 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jan 2021 18:01:38 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A5A091804DC for ; Fri, 15 Jan 2021 09:40:24 -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.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from web138.dnchosting.com (web138.dnchosting.com [104.171.28.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 15 Jan 2021 09:40:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=colannino.dev; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6DwipPxR43fkwygIXcYohDMvoU7Cs8v93nx4/plvWvc=; b=aN8zGBtmYIoqDPapiSYZPLCbN6 Ii2qX/cCU3vOJcAWi+o+XeRZdhNqyDSNVtFa7bcP8P99SqIJcenbSvf8t7k5ElLQtFCAFu2x9tt2J 0h+NXTwsKzbA5Uq2DTT8TJenPvc96bFcYKATK+TGq8lQVSEZTFqAYHBjRmClEklB8fsamFRs7O/8c KGqdp1Gv/LlG0nJLiJbxji1HtbnJzg9XGqEYX8JsrTeSorNYwuzrAN807aLIC7zIFFbjX63vtxypS 5dHI5k97D4FODPLU6fhnf+jzMb3bqXF2Yq78+FtGtC73EW5iYyeafWDFVZPapNc3Bom7sy5DCqyY1 /cfSnvXg==; Received: from cpe-23-243-43-243.socal.res.rr.com ([23.243.43.243]:54012 helo=[192.168.0.12]) by web138.dnchosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1l0T57-0005vf-Ct for internals@lists.php.net; Fri, 15 Jan 2021 17:40:23 +0000 To: internals@lists.php.net References: <90e4acaa-899d-9a20-1653-f58a2a04aeb6@colannino.dev> Message-ID: Date: Fri, 15 Jan 2021 09:40:17 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-OutGoing-Spam-Status: No, score=-0.5 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - web138.dnchosting.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - colannino.dev X-Get-Message-Sender-Via: web138.dnchosting.com: authenticated_id: james@colannino.dev X-Authenticated-Sender: web138.dnchosting.com: james@colannino.dev X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, there is a forwarder that points to the actual sender. Subject: Re: [PHP-DEV] Arg info / zpp mismatch on PHP 8.0 From: composer@colannino.dev (James Colannino) On 1/15/21 9:20 AM, James Colannino wrote: > > On 1/15/21 9:15 AM, Nikita Popov wrote: >> On Fri, Jan 15, 2021 at 6:11 PM James Colannino >> wrote: >> >>> I have the following method defined in a PHP 8 extension: >>> >>> ZEND_BEGIN_ARG_INFO(arginfoCtor, 0) >>>       ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0) >>>       ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 1) >>> ZEND_END_ARG_INFO() >>> >>> PHP_METHOD(Trogdord, __construct) { >>> >>>       trogdordObject *objWrapper = >>> ZOBJ_TO_TROGDORD(Z_OBJ_P(getThis())); >>> >>>       char *hostname; >>>       size_t hostnameLength; >>>       long port = TROGDORD_DEFAULT_PORT; >>> >>>       zend_parse_parameters_throw( >>>           ZEND_NUM_ARGS(), >>>           "s|l", >>>           &hostname, >>>           &hostnameLength, >>>           &port >>>       ); >>> >>>       ... >>> } >>> >>> This works fine on PHP 7, but on PHP 8, I get an "Arg info / zpp >>> mismatch" error. I discovered that if I comment out >>> "ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 1)", it works, but I'd like to >>> type hint that second optional argument if possible. Maybe I was always >>> doing this the wrong way, but I thought that the last argument 1 to >>> allow null was the proper way to handle this and I'm not sure why it >>> results in an error now. >>> >>> Can anyone tell me the correct way to approach this in PHP 8? Thank >>> you! >>> >> Your arginfo declares the arugment as nullable, but your zpp call >> does not. >> Thus the error. You need: >> >>       zend_bool port_is_null = 1; >>       zend_parse_parameters_throw( >>           ZEND_NUM_ARGS(), >>           "s|l!", // ! means nullable >>           &hostname, >>           &hostnameLength, >>           &port, >>           &port_is_null // Whether null was actually passed >>       ); > > > I tried that, but I still get the "Arginfo / zpp mismatch during call" > error. This is the code I have now, which is still giving me the error on PHP 8: ZEND_BEGIN_ARG_INFO(arginfoCtor, 0)     ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0)     ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 1) ZEND_END_ARG_INFO() PHP_METHOD(Trogdord, __construct) {     trogdordObject *objWrapper = ZOBJ_TO_TROGDORD(Z_OBJ_P(getThis()));     char *hostname;     size_t hostnameLength;     long port = TROGDORD_DEFAULT_PORT;     zend_bool portIsNull = 1;     zend_parse_parameters_throw(         ZEND_NUM_ARGS(),         "s|l!",         &hostname,         &hostnameLength,         &port,         &portIsNull     );     ... }