Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112904 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 39031 invoked from network); 15 Jan 2021 17:41:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jan 2021 17:41:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3C6B41804D1 for ; Fri, 15 Jan 2021 09:20:10 -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,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:20:09 -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=3ogzashwrvozFUnEVQt4Bm+OjKkNlLV1Gu+VkosLCsA=; b=hws1tp0c7esMISicUhQFX5wtZS /1emdAcuBSboboJTezlvPxqbCNhprfHY9Q87hLlSs1YHj5sKK4UPYWrt/YgXKdTUK5JcWb09D5Vt7 Yf2KNbeQ4+JjtCZ5uoYPppQ2c3Id7PKvt5VpHT+7XXUuIHfIqb6QA9ZWyIePeDlXCvQUHi2DRYgU0 TIWr2A8Wbe6HoywT0SuAuxgxJsQi7/Eb6+Q33P3UbmK+dkYYLxOftAhbyzhTiStrXoJzomlBI4eQg qjRB9XoBA1fG85rhm1qJ/qInmWoOY+SOVVwmOPKJrjbBO3TaqEHQ81m+IQJnzQglqmrsrRCUDlyhg S7vuHSGw==; Received: from cpe-23-243-43-243.socal.res.rr.com ([23.243.43.243]:53876 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 1l0SlV-0005vn-Fi for internals@lists.php.net; Fri, 15 Jan 2021 17:20:08 +0000 To: internals@lists.php.net References: <90e4acaa-899d-9a20-1653-f58a2a04aeb6@colannino.dev> Message-ID: Date: Fri, 15 Jan 2021 09:20:01 -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: 7bit 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: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.