Arg info / zpp mismatch on PHP 8.0
| From: | James Colannino | Date: | Fri, 15 Jan 2021 17:10:56 +0000 |
| Subject: | Arg info / zpp mismatch on PHP 8.0 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-112902@lists.php.net to get a copy of this message | ||
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!