Skip to content

Commit

Permalink
Arginfo stubs for fun.c (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb authored Nov 19, 2021
1 parent 5c05bcb commit 0f6a27e
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 63 deletions.
42 changes: 0 additions & 42 deletions fun.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,33 +27,6 @@
#include "Zend/zend_exceptions.h"
#include "ext/spl/spl_exceptions.h"

/* {{{ arginfo */
ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_get_err_descs, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_err2name, 0, 0, 1)
ZEND_ARG_INFO(0, err)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_err2str, 0, 0, 1)
ZEND_ARG_INFO(0, err)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_errno2err, 0, 0, 1)
ZEND_ARG_INFO(0, errnox)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_errno, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_thread_cnt, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_kafka_offset_tail, 0, 0, 1)
ZEND_ARG_INFO(0, cnt)
ZEND_END_ARG_INFO()
/* }}} */

/* {{{ proto array rd_kafka_get_err_descs()
* Returns the full list of error codes.
*/
Expand Down Expand Up @@ -194,18 +167,3 @@ PHP_FUNCTION(rd_kafka_offset_tail)
RETURN_LONG(RD_KAFKA_OFFSET_TAIL(cnt));
}
/* }}} */

/* {{{ rdkafka_functions[]
*/
const zend_function_entry rdkafka_functions[] = {
PHP_FE(rd_kafka_get_err_descs, arginfo_kafka_get_err_descs)
PHP_FE(rd_kafka_err2name, arginfo_kafka_err2name)
PHP_FE(rd_kafka_err2str, arginfo_kafka_err2str)
PHP_DEP_FE(rd_kafka_errno2err, arginfo_kafka_errno2err)
PHP_DEP_FE(rd_kafka_errno, arginfo_kafka_errno)
PHP_FE(rd_kafka_offset_tail, arginfo_kafka_offset_tail)
PHP_FE(rd_kafka_thread_cnt, arginfo_kafka_thread_cnt)
PHP_FE_END /* Must be the last line in rdkafka_functions[] */
};
/* }}} */

19 changes: 0 additions & 19 deletions fun.h

This file was deleted.

22 changes: 22 additions & 0 deletions fun.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

/**
* @generate-function-entries
* @generate-legacy-arginfo
*/

function rd_kafka_get_err_descs(): array {}

function rd_kafka_err2name(int $err): ?string {}

function rd_kafka_err2str(int $err): ?string {}

/** @deprecated */
function rd_kafka_errno2err(int $errnox): int {}

/** @deprecated */
function rd_kafka_errno(): int {}

function rd_kafka_offset_tail(int $cnt): int {}

function rd_kafka_thread_cnt(): int {}
45 changes: 45 additions & 0 deletions fun_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 0e1e56d853a47168a1f7f0950b674c2de6a91976 */

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rd_kafka_get_err_descs, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rd_kafka_err2name, 0, 1, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, err, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_rd_kafka_err2str arginfo_rd_kafka_err2name

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rd_kafka_errno2err, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, errnox, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rd_kafka_errno, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rd_kafka_offset_tail, 0, 1, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, cnt, IS_LONG, 0)
ZEND_END_ARG_INFO()

#define arginfo_rd_kafka_thread_cnt arginfo_rd_kafka_errno


ZEND_FUNCTION(rd_kafka_get_err_descs);
ZEND_FUNCTION(rd_kafka_err2name);
ZEND_FUNCTION(rd_kafka_err2str);
ZEND_FUNCTION(rd_kafka_errno2err);
ZEND_FUNCTION(rd_kafka_errno);
ZEND_FUNCTION(rd_kafka_offset_tail);
ZEND_FUNCTION(rd_kafka_thread_cnt);


static const zend_function_entry ext_functions[] = {
ZEND_FE(rd_kafka_get_err_descs, arginfo_rd_kafka_get_err_descs)
ZEND_FE(rd_kafka_err2name, arginfo_rd_kafka_err2name)
ZEND_FE(rd_kafka_err2str, arginfo_rd_kafka_err2str)
ZEND_DEP_FE(rd_kafka_errno2err, arginfo_rd_kafka_errno2err)
ZEND_DEP_FE(rd_kafka_errno, arginfo_rd_kafka_errno)
ZEND_FE(rd_kafka_offset_tail, arginfo_rd_kafka_offset_tail)
ZEND_FE(rd_kafka_thread_cnt, arginfo_rd_kafka_thread_cnt)
ZEND_FE_END
};
44 changes: 44 additions & 0 deletions fun_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 0e1e56d853a47168a1f7f0950b674c2de6a91976 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_rd_kafka_get_err_descs, 0, 0, 0)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_rd_kafka_err2name, 0, 0, 1)
ZEND_ARG_INFO(0, err)
ZEND_END_ARG_INFO()

#define arginfo_rd_kafka_err2str arginfo_rd_kafka_err2name

ZEND_BEGIN_ARG_INFO_EX(arginfo_rd_kafka_errno2err, 0, 0, 1)
ZEND_ARG_INFO(0, errnox)
ZEND_END_ARG_INFO()

#define arginfo_rd_kafka_errno arginfo_rd_kafka_get_err_descs

ZEND_BEGIN_ARG_INFO_EX(arginfo_rd_kafka_offset_tail, 0, 0, 1)
ZEND_ARG_INFO(0, cnt)
ZEND_END_ARG_INFO()

#define arginfo_rd_kafka_thread_cnt arginfo_rd_kafka_get_err_descs


ZEND_FUNCTION(rd_kafka_get_err_descs);
ZEND_FUNCTION(rd_kafka_err2name);
ZEND_FUNCTION(rd_kafka_err2str);
ZEND_FUNCTION(rd_kafka_errno2err);
ZEND_FUNCTION(rd_kafka_errno);
ZEND_FUNCTION(rd_kafka_offset_tail);
ZEND_FUNCTION(rd_kafka_thread_cnt);


static const zend_function_entry ext_functions[] = {
ZEND_FE(rd_kafka_get_err_descs, arginfo_rd_kafka_get_err_descs)
ZEND_FE(rd_kafka_err2name, arginfo_rd_kafka_err2name)
ZEND_FE(rd_kafka_err2str, arginfo_rd_kafka_err2str)
ZEND_DEP_FE(rd_kafka_errno2err, arginfo_rd_kafka_errno2err)
ZEND_DEP_FE(rd_kafka_errno, arginfo_rd_kafka_errno)
ZEND_FE(rd_kafka_offset_tail, arginfo_rd_kafka_offset_tail)
ZEND_FE(rd_kafka_thread_cnt, arginfo_rd_kafka_thread_cnt)
ZEND_FE_END
};
5 changes: 3 additions & 2 deletions rdkafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@
#include "message.h"
#include "kafka_consumer.h"
#include "topic_partition.h"
#include "fun.h"
#if PHP_VERSION_ID < 80000
#include "rdkafka_legacy_arginfo.h"
#include "fun_legacy_arginfo.h"
#else
#include "rdkafka_arginfo.h"
#include "fun_arginfo.h"
#endif

#if RD_KAFKA_VERSION < 0x000b0000
Expand Down Expand Up @@ -1007,7 +1008,7 @@ PHP_MINFO_FUNCTION(rdkafka)
zend_module_entry rdkafka_module_entry = {
STANDARD_MODULE_HEADER,
"rdkafka",
rdkafka_functions,
ext_functions,
PHP_MINIT(rdkafka),
NULL,
NULL,
Expand Down

0 comments on commit 0f6a27e

Please sign in to comment.