Skip to content

Commit d137a46

Browse files
committed
Fix PHPStan Errors
Signed-off-by: Lukas Kämmerling <lukas.kaemmerling@hetzner-cloud.de>
1 parent c520108 commit d137a46

File tree

6 files changed

+12
-20
lines changed

6 files changed

+12
-20
lines changed

src/Prometheus/RenderTextFormat.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private function escapeLabelValue(string $v): string
5454
}
5555

5656
/**
57-
* @param string[] $labelNames
57+
* @param string[] $labelNames
5858
* @param Sample $sample
5959
*
6060
* @return string[]
@@ -65,12 +65,8 @@ private function escapeAllLabels(array $labelNames, Sample $sample): array
6565

6666
$labels = array_combine(array_merge($labelNames, $sample->getLabelNames()), $sample->getLabelValues());
6767

68-
if ($labels === false) {
69-
return [];
70-
}
71-
7268
foreach ($labels as $labelName => $labelValue) {
73-
$escapedLabels[] = $labelName . '="' . $this->escapeLabelValue((string) $labelValue) . '"';
69+
$escapedLabels[] = $labelName . '="' . $this->escapeLabelValue((string)$labelValue) . '"';
7470
}
7571

7672
return $escapedLabels;

tests/Test/Prometheus/AbstractCounterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
205205
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
206206
$sample->getLabelValues()
207207
);
208-
self::assertIsArray($labels);
209208
self::assertEquals($value, $labels[$label]);
210209
}
211210
}

tests/Test/Prometheus/AbstractGaugeTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
339339
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
340340
$sample->getLabelValues()
341341
);
342-
self::assertIsArray($labels);
343342
self::assertEquals($value, $labels[$label]);
344343
}
345344
}

tests/Test/Prometheus/AbstractHistogramTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
490490
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
491491
$sample->getLabelValues()
492492
);
493-
self::assertIsArray($labels);
494493
self::assertEquals($value, $labels[$label]);
495494
}
496495
}

tests/Test/Prometheus/AbstractSummaryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,6 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
586586
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
587587
$sample->getLabelValues()
588588
);
589-
self::assertIsArray($labels);
590589
self::assertEquals($value, $labels[$label]);
591590
}
592591
}

tests/Test/Prometheus/Storage/RedisTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public function itShouldThrowExceptionWhenInjectedRedisIsNotConnected(): void
4646
{
4747
$connection = new \Redis();
4848

49-
$this->expectException(StorageException::class);
50-
$this->expectExceptionMessage('Connection to Redis server not established');
49+
self::expectException(StorageException::class);
50+
self::expectExceptionMessage('Connection to Redis server not established');
5151

5252
Redis::fromExistingConnection($connection);
5353
}
@@ -92,22 +92,22 @@ public function itShouldOnlyConnectOnceOnSubsequentCalls(): void
9292

9393
$redis->collect();
9494

95-
$this->assertStringContainsString(
95+
self::assertStringContainsString(
9696
$expectedClientId,
9797
$this->redisConnection->rawCommand('client', 'list')
9898
);
99-
$this->assertStringNotContainsString(
99+
self::assertStringNotContainsString(
100100
$notExpectedClientId,
101101
$this->redisConnection->rawCommand('client', 'list')
102102
);
103103

104104
$redis->collect();
105105

106-
$this->assertStringContainsString(
106+
self::assertStringContainsString(
107107
$expectedClientId,
108108
$this->redisConnection->rawCommand('client', 'list')
109109
);
110-
$this->assertStringNotContainsString(
110+
self::assertStringNotContainsString(
111111
$notExpectedClientId,
112112
$this->redisConnection->rawCommand('client', 'list')
113113
);
@@ -126,22 +126,22 @@ public function itShouldOnlyConnectOnceForInjectedRedisConnectionOnSubsequentCal
126126

127127
$redis->collect();
128128

129-
$this->assertStringContainsString(
129+
self::assertStringContainsString(
130130
$expectedClientId,
131131
$this->redisConnection->rawCommand('client', 'list')
132132
);
133-
$this->assertStringNotContainsString(
133+
self::assertStringNotContainsString(
134134
$notExpectedClientId,
135135
$this->redisConnection->rawCommand('client', 'list')
136136
);
137137

138138
$redis->collect();
139139

140-
$this->assertStringContainsString(
140+
self::assertStringContainsString(
141141
$expectedClientId,
142142
$this->redisConnection->rawCommand('client', 'list')
143143
);
144-
$this->assertStringNotContainsString(
144+
self::assertStringNotContainsString(
145145
$notExpectedClientId,
146146
$this->redisConnection->rawCommand('client', 'list')
147147
);

0 commit comments

Comments
 (0)