Skip to content

Commit 1abd37d

Browse files
committed
Remove unnecessary var annotations
1 parent 1ea84cb commit 1abd37d

File tree

2 files changed

+17
-50
lines changed

2 files changed

+17
-50
lines changed

.phpstorm.meta.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace PHPSTORM_META {
44

5+
use Grongor\KafkaRest\Api\HttpRestClient;
56
use Mockery;
67

78
override(Mockery::mock(0), type(0));
9+
override(HttpRestClient::execute(1), type(0));
810
}
9-

src/Api/HttpRestClient.php

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -75,78 +75,59 @@ public function __construct(
7575
/** {@inheritDoc} */
7676
public function listTopics() : array
7777
{
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>');
8279
}
8380

8481
/** {@inheritDoc} */
8582
public function getTopic(string $topic) : Topic
8683
{
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);
9185
}
9286

9387
/** {@inheritDoc} */
9488
public function produce(string $topic, iterable $messages) : array
9589
{
96-
/** @var ProduceResults $result */
97-
$result = $this->execute(
90+
return $this->execute(
9891
$this->post(sprintf('/topics/%s', $topic), $this->serialize(['records' => $messages])),
9992
ProduceResults::class
100-
);
101-
102-
return $result->results;
93+
)->results;
10394
}
10495

10596
/** {@inheritDoc} */
10697
public function listPartitions(string $topic) : array
10798
{
108-
/** @var Partition[] $partitions */
109-
$partitions = $this->execute(
99+
return $this->execute(
110100
$this->get(sprintf('/topics/%s/partitions', $topic)),
111101
sprintf('array<%s>', Partition::class)
112102
);
113-
114-
return $partitions;
115103
}
116104

117105
/** {@inheritDoc} */
118106
public function getPartition(string $topic, int $partition) : Partition
119107
{
120-
/** @var Partition $result */
121-
$result = $this->execute(
108+
return $this->execute(
122109
$this->get(sprintf('/topics/%s/partitions/%d', $topic, $partition)),
123110
Partition::class
124111
);
125-
126-
return $result;
127112
}
128113

129114
/** {@inheritDoc} */
130115
public function produceToPartition(string $topic, int $partition, iterable $messages) : array
131116
{
132-
/** @var ProduceResults $result */
133-
$result = $this->execute(
117+
return $this->execute(
134118
$this->post(
135119
sprintf('/topics/%s/partitions/%d', $topic, $partition),
136120
$this->serialize(['records' => $messages])
137121
),
138122
ProduceResults::class
139-
);
140-
141-
return $result->results;
123+
)->results;
142124
}
143125

144126
/** {@inheritDoc} */
145127
public function createConsumer(string $group, ?ConsumerOptions $consumerOptions = null) : Consumer
146128
{
147129
$consumerOptions = $consumerOptions ?? new ConsumerOptions();
148130

149-
/** @var Consumer $consumer */
150131
$consumer = $this->execute(
151132
$this->post(sprintf('/consumers/%s', $group), $this->serialize($consumerOptions)),
152133
Consumer::class
@@ -180,13 +161,10 @@ public function consumerCommitOffsets(Consumer $consumer, ?iterable $offsets = n
180161
/** {@inheritDoc} */
181162
public function getConsumerCommittedOffsets(Consumer $consumer, iterable $partitions) : array
182163
{
183-
/** @var array<string, array<Offset>> $result */
184-
$result = $this->execute(
164+
return $this->execute(
185165
$this->consumerGet($consumer, '/offsets', $this->serialize(['partitions' => $partitions])),
186166
sprintf('array<string, array<%s>>', Offset::class)
187-
);
188-
189-
return $result['offsets'];
167+
)['offsets'];
190168
}
191169

192170
/** {@inheritDoc} */
@@ -198,10 +176,7 @@ public function consumerSubscribe(Consumer $consumer, Subscription $subscription
198176
/** {@inheritDoc} */
199177
public function getConsumerSubscribedTopics(Consumer $consumer) : array
200178
{
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'];
205180
}
206181

207182
/** {@inheritDoc} */
@@ -219,13 +194,10 @@ public function consumerAssignPartitions(Consumer $consumer, iterable $partition
219194
/** {@inheritDoc} */
220195
public function getConsumerAssignedPartitions(Consumer $consumer) : array
221196
{
222-
/** @var array<string, array<AssignedPartition>> $result */
223-
$result = $this->execute(
197+
return $this->execute(
224198
$this->consumerGet($consumer, '/assignments'),
225199
sprintf('array<string, array<%s>>', AssignedPartition::class)
226-
);
227-
228-
return $result['partitions'];
200+
)['partitions'];
229201
}
230202

231203
/** {@inheritDoc} */
@@ -265,19 +237,13 @@ public function getConsumerMessages(Consumer $consumer, ?int $timeout = null, ?i
265237
$request = $this->consumerGet($consumer, '/records');
266238
$request = $request->withUri($request->getUri()->withQuery(http_build_query($parameters)), true);
267239

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));
272241
}
273242

274243
/** {@inheritDoc} */
275244
public function getBrokers() : array
276245
{
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'];
281247
}
282248

283249
private function request(string $method, string $path, ?UriInterface $baseUri = null) : RequestInterface

0 commit comments

Comments
 (0)