From d840cf4d980ff6979e1f673c63a34c091efeb78e Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 7 Dec 2021 10:28:21 +0100 Subject: [PATCH] Fix newTopic() arginfo (#502) --- kafka_consumer.stub.php | 2 +- kafka_consumer_arginfo.h | 4 ++-- kafka_consumer_legacy_arginfo.h | 2 +- package.xml | 1 + rdkafka.stub.php | 2 +- rdkafka_arginfo.h | 4 ++-- rdkafka_legacy_arginfo.h | 2 +- tests/new_topic_with_conf.phpt | 31 +++++++++++++++++++++++++++++++ 8 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 tests/new_topic_with_conf.phpt diff --git a/kafka_consumer.stub.php b/kafka_consumer.stub.php index 1b95a09e..539b5085 100644 --- a/kafka_consumer.stub.php +++ b/kafka_consumer.stub.php @@ -49,7 +49,7 @@ public function unsubscribe(): void {} public function getMetadata(bool $all_topics, Topic $only_topic, int $timeout_ms): Metadata {} /** @tentative-return-type */ - public function newTopic(string $topic_name, ?Conf $topic_conf = null): KafkaConsumerTopic {} + public function newTopic(string $topic_name, ?TopicConf $topic_conf = null): KafkaConsumerTopic {} /** @tentative-return-type */ public function getCommittedOffsets(array $topic_partitions, int $timeout_ms): array {} diff --git a/kafka_consumer_arginfo.h b/kafka_consumer_arginfo.h index fd4a4244..ec524f1e 100644 --- a/kafka_consumer_arginfo.h +++ b/kafka_consumer_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 777873a7819e8d15fbcdd0390c33489658fd4de3 */ + * Stub hash: aee362c9762bd72d620b36f1e5686d96e09b9cac */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka_KafkaConsumer___construct, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, conf, RdKafka\\Conf, 0) @@ -41,7 +41,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_RdKafka_KafkaConsumer_newTopic, 0, 1, RdKafka\\KafkaConsumerTopic, 0) ZEND_ARG_TYPE_INFO(0, topic_name, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, topic_conf, RdKafka\\Conf, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, topic_conf, RdKafka\\TopicConf, 1, "null") ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_RdKafka_KafkaConsumer_getCommittedOffsets, 0, 2, IS_ARRAY, 0) diff --git a/kafka_consumer_legacy_arginfo.h b/kafka_consumer_legacy_arginfo.h index cc691b18..74794827 100644 --- a/kafka_consumer_legacy_arginfo.h +++ b/kafka_consumer_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 777873a7819e8d15fbcdd0390c33489658fd4de3 */ + * Stub hash: aee362c9762bd72d620b36f1e5686d96e09b9cac */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka_KafkaConsumer___construct, 0, 0, 1) ZEND_ARG_INFO(0, conf) diff --git a/package.xml b/package.xml index 8500d6e1..10676ac7 100644 --- a/package.xml +++ b/package.xml @@ -122,6 +122,7 @@ + diff --git a/rdkafka.stub.php b/rdkafka.stub.php index 2a68c23a..be04e20c 100644 --- a/rdkafka.stub.php +++ b/rdkafka.stub.php @@ -37,7 +37,7 @@ public function metadata(bool $all_topics, ?RdKafka\Topic $only_topic, int $time public function setLogLevel(int $level): void {} /** @tentative-return-type */ - public function newTopic(string $topic_name, ?RdKafka\Conf $topic_conf = null): RdKafka\Topic {} + public function newTopic(string $topic_name, ?RdKafka\TopicConf $topic_conf = null): RdKafka\Topic {} /** * @alias RdKafka::getOutQLen diff --git a/rdkafka_arginfo.h b/rdkafka_arginfo.h index 9900a6ec..1f8e168c 100644 --- a/rdkafka_arginfo.h +++ b/rdkafka_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 534b40ff0c32bc39196c1735bdd6d5676a073e6f */ + * Stub hash: fbfdb28740208d5f909e9db261bea0aa26bfd471 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka___construct, 0, 0, 0) ZEND_END_ARG_INFO() @@ -25,7 +25,7 @@ ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_OBJ_INFO_EX(arginfo_class_RdKafka_newTopic, 0, 1, RdKafka\\Topic, 0) ZEND_ARG_TYPE_INFO(0, topic_name, IS_STRING, 0) - ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, topic_conf, RdKafka\\Conf, 1, "null") + ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, topic_conf, RdKafka\\TopicConf, 1, "null") ZEND_END_ARG_INFO() #define arginfo_class_RdKafka_outqLen arginfo_class_RdKafka_getOutQLen diff --git a/rdkafka_legacy_arginfo.h b/rdkafka_legacy_arginfo.h index 91d89279..eb7e64b6 100644 --- a/rdkafka_legacy_arginfo.h +++ b/rdkafka_legacy_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 534b40ff0c32bc39196c1735bdd6d5676a073e6f */ + * Stub hash: fbfdb28740208d5f909e9db261bea0aa26bfd471 */ ZEND_BEGIN_ARG_INFO_EX(arginfo_class_RdKafka___construct, 0, 0, 0) ZEND_END_ARG_INFO() diff --git a/tests/new_topic_with_conf.phpt b/tests/new_topic_with_conf.phpt new file mode 100644 index 00000000..2967a302 --- /dev/null +++ b/tests/new_topic_with_conf.phpt @@ -0,0 +1,31 @@ +--TEST-- +newTopic with topic conf +--SKIPIF-- +set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS')); + +$topicName = "test"; +$topicConf = new RdKafka\TopicConf(); + +$producer = new RdKafka\Producer($conf); +var_dump(get_class($producer->newtopic($topicName, $topicConf))); + +$conf = new RdKafka\Conf(); +$conf->set('metadata.broker.list', getenv('TEST_KAFKA_BROKERS')); +$conf->set('group.id', sprintf("test_rdkafka_group_%s", uniqid())); + +$consumer = new RdKafka\Consumer($conf); +var_dump(get_class($consumer->newtopic($topicName, $topicConf))); + +$kafkaConsumer = new RdKafka\KafkaConsumer($conf); +var_dump(get_class($kafkaConsumer->newtopic($topicName, $topicConf))); +--EXPECT-- +string(21) "RdKafka\ProducerTopic" +string(21) "RdKafka\ConsumerTopic" +string(26) "RdKafka\KafkaConsumerTopic"