@@ -75,78 +75,59 @@ public function __construct(
75
75
/** {@inheritDoc} */
76
76
public function listTopics () : array
77
77
{
78
- /** @var array<string> $topics */
79
- $ topics = $ this ->execute ($ this ->get ('/topics ' ), 'array<string> ' );
80
-
81
- return $ topics ;
78
+ return $ this ->execute ($ this ->get ('/topics ' ), 'array<string> ' );
82
79
}
83
80
84
81
/** {@inheritDoc} */
85
82
public function getTopic (string $ topic ) : Topic
86
83
{
87
- /** @var Topic $result */
88
- $ result = $ this ->execute ($ this ->get (sprintf ('/topics/%s ' , $ topic )), Topic::class);
89
-
90
- return $ result ;
84
+ return $ this ->execute ($ this ->get (sprintf ('/topics/%s ' , $ topic )), Topic::class);
91
85
}
92
86
93
87
/** {@inheritDoc} */
94
88
public function produce (string $ topic , iterable $ messages ) : array
95
89
{
96
- /** @var ProduceResults $result */
97
- $ result = $ this ->execute (
90
+ return $ this ->execute (
98
91
$ this ->post (sprintf ('/topics/%s ' , $ topic ), $ this ->serialize (['records ' => $ messages ])),
99
92
ProduceResults::class
100
- );
101
-
102
- return $ result ->results ;
93
+ )->results ;
103
94
}
104
95
105
96
/** {@inheritDoc} */
106
97
public function listPartitions (string $ topic ) : array
107
98
{
108
- /** @var Partition[] $partitions */
109
- $ partitions = $ this ->execute (
99
+ return $ this ->execute (
110
100
$ this ->get (sprintf ('/topics/%s/partitions ' , $ topic )),
111
101
sprintf ('array<%s> ' , Partition::class)
112
102
);
113
-
114
- return $ partitions ;
115
103
}
116
104
117
105
/** {@inheritDoc} */
118
106
public function getPartition (string $ topic , int $ partition ) : Partition
119
107
{
120
- /** @var Partition $result */
121
- $ result = $ this ->execute (
108
+ return $ this ->execute (
122
109
$ this ->get (sprintf ('/topics/%s/partitions/%d ' , $ topic , $ partition )),
123
110
Partition::class
124
111
);
125
-
126
- return $ result ;
127
112
}
128
113
129
114
/** {@inheritDoc} */
130
115
public function produceToPartition (string $ topic , int $ partition , iterable $ messages ) : array
131
116
{
132
- /** @var ProduceResults $result */
133
- $ result = $ this ->execute (
117
+ return $ this ->execute (
134
118
$ this ->post (
135
119
sprintf ('/topics/%s/partitions/%d ' , $ topic , $ partition ),
136
120
$ this ->serialize (['records ' => $ messages ])
137
121
),
138
122
ProduceResults::class
139
- );
140
-
141
- return $ result ->results ;
123
+ )->results ;
142
124
}
143
125
144
126
/** {@inheritDoc} */
145
127
public function createConsumer (string $ group , ?ConsumerOptions $ consumerOptions = null ) : Consumer
146
128
{
147
129
$ consumerOptions = $ consumerOptions ?? new ConsumerOptions ();
148
130
149
- /** @var Consumer $consumer */
150
131
$ consumer = $ this ->execute (
151
132
$ this ->post (sprintf ('/consumers/%s ' , $ group ), $ this ->serialize ($ consumerOptions )),
152
133
Consumer::class
@@ -180,13 +161,10 @@ public function consumerCommitOffsets(Consumer $consumer, ?iterable $offsets = n
180
161
/** {@inheritDoc} */
181
162
public function getConsumerCommittedOffsets (Consumer $ consumer , iterable $ partitions ) : array
182
163
{
183
- /** @var array<string, array<Offset>> $result */
184
- $ result = $ this ->execute (
164
+ return $ this ->execute (
185
165
$ this ->consumerGet ($ consumer , '/offsets ' , $ this ->serialize (['partitions ' => $ partitions ])),
186
166
sprintf ('array<string, array<%s>> ' , Offset::class)
187
- );
188
-
189
- return $ result ['offsets ' ];
167
+ )['offsets ' ];
190
168
}
191
169
192
170
/** {@inheritDoc} */
@@ -198,10 +176,7 @@ public function consumerSubscribe(Consumer $consumer, Subscription $subscription
198
176
/** {@inheritDoc} */
199
177
public function getConsumerSubscribedTopics (Consumer $ consumer ) : array
200
178
{
201
- /** @var array<string, array<string>> $result */
202
- $ result = $ this ->execute ($ this ->consumerGet ($ consumer , '/subscription ' ), 'array<string, array<string>> ' );
203
-
204
- return $ result ['topics ' ];
179
+ return $ this ->execute ($ this ->consumerGet ($ consumer , '/subscription ' ), 'array<string, array<string>> ' )['topics ' ];
205
180
}
206
181
207
182
/** {@inheritDoc} */
@@ -219,13 +194,10 @@ public function consumerAssignPartitions(Consumer $consumer, iterable $partition
219
194
/** {@inheritDoc} */
220
195
public function getConsumerAssignedPartitions (Consumer $ consumer ) : array
221
196
{
222
- /** @var array<string, array<AssignedPartition>> $result */
223
- $ result = $ this ->execute (
197
+ return $ this ->execute (
224
198
$ this ->consumerGet ($ consumer , '/assignments ' ),
225
199
sprintf ('array<string, array<%s>> ' , AssignedPartition::class)
226
- );
227
-
228
- return $ result ['partitions ' ];
200
+ )['partitions ' ];
229
201
}
230
202
231
203
/** {@inheritDoc} */
@@ -265,19 +237,13 @@ public function getConsumerMessages(Consumer $consumer, ?int $timeout = null, ?i
265
237
$ request = $ this ->consumerGet ($ consumer , '/records ' );
266
238
$ request = $ request ->withUri ($ request ->getUri ()->withQuery (http_build_query ($ parameters )), true );
267
239
268
- /** @var array<Message> $messages */
269
- $ messages = $ this ->execute ($ request , sprintf ('array<%s> ' , Message::class));
270
-
271
- return $ messages ;
240
+ return $ this ->execute ($ request , sprintf ('array<%s> ' , Message::class));
272
241
}
273
242
274
243
/** {@inheritDoc} */
275
244
public function getBrokers () : array
276
245
{
277
- /** @var array<string, array<int>> $result */
278
- $ result = $ this ->execute ($ this ->get ('/brokers ' ), 'array<string, array<int>> ' );
279
-
280
- return $ result ['brokers ' ];
246
+ return $ this ->execute ($ this ->get ('/brokers ' ), 'array<string, array<int>> ' )['brokers ' ];
281
247
}
282
248
283
249
private function request (string $ method , string $ path , ?UriInterface $ baseUri = null ) : RequestInterface
0 commit comments