Skip to content

Commit

Permalink
Fix newTopic() arginfo (#502)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-lb authored Dec 7, 2021
1 parent 990a489 commit d840cf4
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion kafka_consumer.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions kafka_consumer_arginfo.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion kafka_consumer_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<file role="test" name="integration-tests-check.php"/>
<file role="test" name="kafka_error_exception.phpt"/>
<file role="test" name="message_headers.phpt"/>
<file role="test" name="new_topic_with_conf.phpt"/>
<file role="test" name="pause_resume.phpt"/>
<file role="test" name="produce_consume.phpt"/>
<file role="test" name="produce_consume_queue.phpt"/>
Expand Down
2 changes: 1 addition & 1 deletion rdkafka.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions rdkafka_arginfo.h
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rdkafka_legacy_arginfo.h
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
31 changes: 31 additions & 0 deletions tests/new_topic_with_conf.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
--TEST--
newTopic with topic conf
--SKIPIF--
<?php
require __DIR__ . '/integration-tests-check.php';
--FILE--
<?php
require __DIR__ . '/integration-tests-check.php';

$conf = new RdKafka\Conf();
$conf->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"

0 comments on commit d840cf4

Please sign in to comment.