Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112906 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 44874 invoked from network); 15 Jan 2021 18:39:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Jan 2021 18:39:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0B8FA1804DC for ; Fri, 15 Jan 2021 10:18:08 -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.1 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (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 ; Fri, 15 Jan 2021 10:18:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1610734635; bh=MsuF3fXKwMkRnAuemArDNUPa2hvKcUNKDkHmSH37nq8=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=UQS4YuYDZQl8yC6t/yKkGC+fo44fi7+CDQ4yBBhrweLEVUsBfuPJHufFfLfsePsza FSU9HR1JMEvsuHNSggcBTgv7IMSxiTzEozmDuVCeJg8QSwT3DhDQzsC+X4m79/91Py qqTvqdTSRg+1PKjDo0mjJnB6rVZnDJfNx8/83uyo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([79.222.34.4]) by mail.gmx.com (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M3DO3-1l3USk0Sq5-003d1E; Fri, 15 Jan 2021 19:17:15 +0100 To: James Colannino , internals@lists.php.net References: <90e4acaa-899d-9a20-1653-f58a2a04aeb6@colannino.dev> Message-ID: <76a97cce-8707-48aa-763b-20970eaa18db@gmx.de> Date: Fri, 15 Jan 2021 19:17:13 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:tJTw7y1zgmP3Wn0BJ7P3g9w52UOosZ5DvHWStvhR4sRH9KhH45b ovzOFb1/FQ8b6Q1svxlj+Wy+C/AANNLy1mpqFKNIR35yt0mW23kBjabBUrOwxvEW4mQkE3X jwu0zUVKviHvW7Z3NOkRSvRFVEErx9dcyHXXSXBYXFemkZFCM9CP5TxB3iEPxlIr/ss3sxS I9BIuyz2YHHofnvyYVhRw== X-UI-Out-Filterresults: notjunk:1;V03:K0:9FD+5EVOScI=:MsOrLx59wBNGKYd3WDaOK/ AFEx36+99ecNtGknZCJY23hooPSyZXZvtywElUGkx5bxwTbG96XNptYtAd9byNDFp274BoF8Y 1vAqjp48yNnbuvI8sKULJiwO3QjL1RH68Rjy666bPH6nuzcjBNiK3kg8dCqu1FFmbHZl7HK+v J6gpYRhtV4gWO5MKAJZW+HHNEXGuAKAgQAzfWpC1w91Bt7+8nDGU8C4OeCjhcuH3vVAC6fzuz E9uwB5/p6Phh9dsPVc+bZLnbu92l2CwSFc1SCVJokw+bdxio/Q3286qI1Z7dfsQyFPLxyNNCH 6rkPFV4XoSf0TxPVBUGEcnF6gn0T4JatHfbu2WYKwLs3XISoKJSuXo2pttmdaxu6ZiaqWhqgD Ycj5iziZNP/P607+WGLn5n/qt1rIWm2qhdSDJjH7707UkUaqUQb1evqrw00ZNBBjveZ3zIPgS q+db0JoMLlEIV1ImVjDiRxdkq7gInEiXOPKAnIArkBkMyTpFXfqu9AIownAdMpV9AxSi9j381 4aya3HfxOPhzshGPJ5h3P2RhKbMzvGU048b1XgXQ+OPxefG3e3ogyWfYDc8bPY8hkvy0E9LTm 2QvJ0AvBvpsQEaySFiIra8ez9PP+o6CN6IBQcXA3zNpVWN3iSO9SL1ukPfudCfz9kSnZdyi0E +cxj13iebUJjA9+awntYSn2YlaDvCL3lWjhBOCpC64qfgA7Fowj4stI3PBneCMPoeFvITah/e ydBTclF6MYk0bLXUUJZ9zQSs4v+SObnrB5h1xyFcYPGa4gX1adDpl0uqR4Zpvd6k9HJ0Thzbh Q56YkjDgj3byDtHn+aa9BoDQlYuw7U1XszBKH6iQBFF4DxexS7eyOoyOTkjCxVkp5fsVAtzZB aeVhhjJ3LHaPQZZlnBfA== Subject: Re: [PHP-DEV] Arg info / zpp mismatch on PHP 8.0 From: cmbecker69@gmx.de ("Christoph M. Becker") On 15.01.2021 at 18:40, James Colannino wrote: > 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) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ZEND_ARG_TYPE_INFO(0, hostname, IS_STR= ING, 0) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 1= ) >>>> ZEND_END_ARG_INFO() >>>> >>>> PHP_METHOD(Trogdord, __construct) { >>>> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 trogdordObject *objWrapper =3D >>>> ZOBJ_TO_TROGDORD(Z_OBJ_P(getThis())); >>>> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 char *hostname; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 size_t hostnameLength; >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 long port =3D TROGDORD_DEFAULT_PORT; >>>> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 zend_parse_parameters_throw( >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ZEND_NUM_ARGS(= ), >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "s|l", >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &hostname, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &hostnameLengt= h, >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &port >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >>>> >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ... >>>> } >>>> >>>> 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 alwa= ys >>>> 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: >>> >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 zend_bool port_is_null =3D 1; >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 zend_parse_parameters_throw( >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ZEND_NUM_ARGS()= , >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "s|l!", // ! me= ans nullable >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &hostname, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &hostnameLength= , >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &port, >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 &port_is_null /= / Whether null was actually passed >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >> >> >> 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) You need to tell arginfo about the optional parameter: ZEND_BEGIN_ARG_INFO_EX(arginfoCtor, 0, 0, 1) However, it is much simpler to write a stub file, and to let build/gen_stub.php generate the arginfo for you. See e.g. . > =C2=A0=C2=A0=C2=A0 ZEND_ARG_TYPE_INFO(0, hostname, IS_STRING, 0) > =C2=A0=C2=A0=C2=A0 ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 1) > ZEND_END_ARG_INFO() > > PHP_METHOD(Trogdord, __construct) { > > =C2=A0=C2=A0=C2=A0 trogdordObject *objWrapper =3D ZOBJ_TO_TROGDORD(Z_OBJ= _P(getThis())); > > =C2=A0=C2=A0=C2=A0 char *hostname; > =C2=A0=C2=A0=C2=A0 size_t hostnameLength; > > =C2=A0=C2=A0=C2=A0 long port =3D TROGDORD_DEFAULT_PORT; > =C2=A0=C2=A0=C2=A0 zend_bool portIsNull =3D 1; > > =C2=A0=C2=A0=C2=A0 zend_parse_parameters_throw( > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ZEND_NUM_ARGS(), > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 "s|l!", > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 &hostname, > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 &hostnameLength, > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 &port, > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 &portIsNull > =C2=A0=C2=A0=C2=A0 ); > > =C2=A0=C2=A0=C2=A0 ... > }