From 32305673ee5ec4ef8b76c199d33b0c236cd805dc Mon Sep 17 00:00:00 2001 From: info2soft Date: Wed, 30 Oct 2024 15:37:42 +0800 Subject: [PATCH] Fix: Exception: longlang\phpkafka\Group\Struct\ConsumerGroupTopic::setTopicName(): Argument #1 ($topicName) must be of type string, int given $partitions[$topic] = $this->getTopicPartitions($topic, $topicMetadatas); Strings containing valid decimal ints, unless the number is preceded by a + sign, will be cast to the int type. E.g. the key "8" will actually be stored under 8. On the other hand "08" will not be cast, as it isn't a valid decimal integer. --- src/Consumer/Assignor/RangeAssignor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Consumer/Assignor/RangeAssignor.php b/src/Consumer/Assignor/RangeAssignor.php index 942f7dc..3114c07 100644 --- a/src/Consumer/Assignor/RangeAssignor.php +++ b/src/Consumer/Assignor/RangeAssignor.php @@ -64,7 +64,7 @@ public function assign(array $topicMetadatas, array $groupMembers): array /** @var ConsumerGroupMemberAssignment $consumerGroupMemberAssignment */ $consumerGroupMemberAssignment = $topicMembers[$topicName][$memberIds[$i]]['assignment']; $consumerGroupTopic = new ConsumerGroupTopic(); - $consumerGroupTopic->setTopicName($topicName); + $consumerGroupTopic->setTopicName((string) $topicName); $consumerGroupTopic->setPartitions(\array_slice($topicPartitions, $start, $length)); $topics = $consumerGroupMemberAssignment->getTopics(); $topics[] = $consumerGroupTopic;