diff --git a/src/Prometheus/Collector.php b/src/Prometheus/Collector.php index a63420e..edf9c58 100644 --- a/src/Prometheus/Collector.php +++ b/src/Prometheus/Collector.php @@ -9,7 +9,7 @@ abstract class Collector { - const RE_METRIC_LABEL_NAME = '/^[a-zA-Z_:][a-zA-Z0-9_:]*$/'; + protected const RE_METRIC_LABEL_NAME = '/^[a-zA-Z_:][a-zA-Z0-9_:]*$/'; /** * @var Adapter @@ -58,7 +58,7 @@ public function __construct(Adapter $storageAdapter, $namespace, $name, $help, $ /** * @return string */ - abstract public function getType(); + abstract public function getType(): string; /** * @return string diff --git a/src/Prometheus/Counter.php b/src/Prometheus/Counter.php index 1b095e5..2cd847d 100644 --- a/src/Prometheus/Counter.php +++ b/src/Prometheus/Counter.php @@ -8,7 +8,7 @@ class Counter extends Collector { - const TYPE = 'counter'; + public const TYPE = 'counter'; /** * @return string diff --git a/src/Prometheus/Gauge.php b/src/Prometheus/Gauge.php index 72189f7..4a65144 100644 --- a/src/Prometheus/Gauge.php +++ b/src/Prometheus/Gauge.php @@ -8,7 +8,7 @@ class Gauge extends Collector { - const TYPE = 'gauge'; + public const TYPE = 'gauge'; /** * @param double $value e.g. 123 diff --git a/src/Prometheus/Histogram.php b/src/Prometheus/Histogram.php index ff1a48f..ab0f13b 100644 --- a/src/Prometheus/Histogram.php +++ b/src/Prometheus/Histogram.php @@ -9,7 +9,7 @@ class Histogram extends Collector { - const TYPE = 'histogram'; + public const TYPE = 'histogram'; /** * @var array|null diff --git a/src/Prometheus/RenderTextFormat.php b/src/Prometheus/RenderTextFormat.php index a5b78dc..a598466 100644 --- a/src/Prometheus/RenderTextFormat.php +++ b/src/Prometheus/RenderTextFormat.php @@ -6,7 +6,7 @@ class RenderTextFormat { - const MIME_TYPE = 'text/plain; version=0.0.4'; + public const MIME_TYPE = 'text/plain; version=0.0.4'; /** * @param MetricFamilySamples[] $metrics diff --git a/src/Prometheus/Sample.php b/src/Prometheus/Sample.php index c8774e8..d1bfdc6 100644 --- a/src/Prometheus/Sample.php +++ b/src/Prometheus/Sample.php @@ -51,7 +51,7 @@ public function getName(): string */ public function getLabelNames(): array { - return (array)$this->labelNames; + return (array) $this->labelNames; } /** @@ -59,7 +59,7 @@ public function getLabelNames(): array */ public function getLabelValues(): array { - return (array)$this->labelValues; + return (array) $this->labelValues; } /** diff --git a/src/Prometheus/Storage/APC.php b/src/Prometheus/Storage/APC.php index 2fe659d..dde3c64 100644 --- a/src/Prometheus/Storage/APC.php +++ b/src/Prometheus/Storage/APC.php @@ -10,7 +10,7 @@ class APC implements Adapter { - const PROMETHEUS_PREFIX = 'prom'; + private const PROMETHEUS_PREFIX = 'prom'; /** * @return MetricFamilySamples[] @@ -251,7 +251,7 @@ private function collectHistograms(): array $acc = 0; $decodedLabelValues = $this->decodeLabelValues($labelValues); foreach ($data['buckets'] as $bucket) { - $bucket = (string)$bucket; + $bucket = (string) $bucket; if (!isset($histogramBuckets[$labelValues][$bucket])) { $data['samples'][] = [ 'name' => $metaData['name'] . '_bucket', diff --git a/src/Prometheus/Storage/Adapter.php b/src/Prometheus/Storage/Adapter.php index 068e1d9..3bcad49 100644 --- a/src/Prometheus/Storage/Adapter.php +++ b/src/Prometheus/Storage/Adapter.php @@ -8,14 +8,14 @@ interface Adapter { - const COMMAND_INCREMENT_INTEGER = 1; - const COMMAND_INCREMENT_FLOAT = 2; - const COMMAND_SET = 3; + public const COMMAND_INCREMENT_INTEGER = 1; + public const COMMAND_INCREMENT_FLOAT = 2; + public const COMMAND_SET = 3; /** * @return MetricFamilySamples[] */ - public function collect(); + public function collect(): array; /** * @param array $data diff --git a/src/Prometheus/Storage/InMemory.php b/src/Prometheus/Storage/InMemory.php index bfd4c70..9c59a0d 100644 --- a/src/Prometheus/Storage/InMemory.php +++ b/src/Prometheus/Storage/InMemory.php @@ -67,7 +67,7 @@ private function collectHistograms(): array $acc = 0; $decodedLabelValues = $this->decodeLabelValues($labelValues); foreach ($data['buckets'] as $bucket) { - $bucket = (string)$bucket; + $bucket = (string) $bucket; if (!isset($histogramBuckets[$labelValues][$bucket])) { $data['samples'][] = [ 'name' => $metaData['name'] . '_bucket', diff --git a/src/Prometheus/Storage/Redis.php b/src/Prometheus/Storage/Redis.php index 5570685..4b31bcd 100644 --- a/src/Prometheus/Storage/Redis.php +++ b/src/Prometheus/Storage/Redis.php @@ -13,7 +13,7 @@ class Redis implements Adapter { - const PROMETHEUS_METRIC_KEYS_SUFFIX = '_METRIC_KEYS'; + private const PROMETHEUS_METRIC_KEYS_SUFFIX = '_METRIC_KEYS'; /** * @var array diff --git a/tests/Test/BlackBoxPushGatewayTest.php b/tests/Test/BlackBoxPushGatewayTest.php index b3ad8ac..6fc33bf 100644 --- a/tests/Test/BlackBoxPushGatewayTest.php +++ b/tests/Test/BlackBoxPushGatewayTest.php @@ -13,7 +13,7 @@ class BlackBoxPushGatewayTest extends TestCase /** * @test */ - public function pushGatewayShouldWork() + public function pushGatewayShouldWork(): void { $adapter = new APC(); $registry = new CollectorRegistry($adapter); diff --git a/tests/Test/BlackBoxTest.php b/tests/Test/BlackBoxTest.php index b4d8a9e..9f43a59 100644 --- a/tests/Test/BlackBoxTest.php +++ b/tests/Test/BlackBoxTest.php @@ -18,7 +18,7 @@ class BlackBoxTest extends TestCase */ private $adapter; - public function setUp() + public function setUp(): void { $this->adapter = getenv('ADAPTER'); $this->client = new Client(['base_uri' => 'http://nginx:80/']); @@ -28,7 +28,7 @@ public function setUp() /** * @test */ - public function gaugesShouldBeOverwritten() + public function gaugesShouldBeOverwritten(): void { $start = microtime(true); $promises = [ @@ -43,7 +43,7 @@ public function gaugesShouldBeOverwritten() echo "\ntime: " . ($end - $start) . "\n"; $metricsResult = $this->client->get('/examples/metrics.php?adapter=' . $this->adapter); - $body = (string)$metricsResult->getBody(); + $body = (string) $metricsResult->getBody(); echo "\nbody: " . $body . "\n"; $this->assertThat( $body, @@ -58,13 +58,13 @@ public function gaugesShouldBeOverwritten() /** * @test */ - public function countersShouldIncrementAtomically() + public function countersShouldIncrementAtomically(): void { $start = microtime(true); $promises = []; $sum = 0; for ($i = 0; $i < 1100; $i++) { - $promises[] = $this->client->getAsync('/examples/some_counter.php?c=' . $i . '&adapter=' . $this->adapter); + $promises[] = $this->client->getAsync('/examples/some_counter.php?c=' . $i . '&adapter=' . $this->adapter); $sum += $i; } @@ -73,7 +73,7 @@ public function countersShouldIncrementAtomically() echo "\ntime: " . ($end - $start) . "\n"; $metricsResult = $this->client->get('/examples/metrics.php?adapter=' . $this->adapter); - $body = (string)$metricsResult->getBody(); + $body = (string) $metricsResult->getBody(); $this->assertThat($body, $this->stringContains('test_some_counter{type="blue"} ' . $sum)); } @@ -81,7 +81,7 @@ public function countersShouldIncrementAtomically() /** * @test */ - public function histogramsShouldIncrementAtomically() + public function histogramsShouldIncrementAtomically(): void { $start = microtime(true); $promises = [ @@ -102,7 +102,7 @@ public function histogramsShouldIncrementAtomically() echo "\ntime: " . ($end - $start) . "\n"; $metricsResult = $this->client->get('/examples/metrics.php?adapter=' . $this->adapter); - $body = (string)$metricsResult->getBody(); + $body = (string) $metricsResult->getBody(); $this->assertThat($body, $this->stringContains(<<adapter = new APC(); $this->adapter->flushAPC(); diff --git a/tests/Test/Prometheus/APC/CounterTest.php b/tests/Test/Prometheus/APC/CounterTest.php index 306ec36..9b3421c 100644 --- a/tests/Test/Prometheus/APC/CounterTest.php +++ b/tests/Test/Prometheus/APC/CounterTest.php @@ -11,7 +11,7 @@ */ class CounterTest extends AbstractCounterTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new APC(); $this->adapter->flushAPC(); diff --git a/tests/Test/Prometheus/APC/GaugeTest.php b/tests/Test/Prometheus/APC/GaugeTest.php index c5dc4f0..b1da8c3 100644 --- a/tests/Test/Prometheus/APC/GaugeTest.php +++ b/tests/Test/Prometheus/APC/GaugeTest.php @@ -11,7 +11,7 @@ */ class GaugeTest extends AbstractGaugeTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new APC(); $this->adapter->flushAPC(); diff --git a/tests/Test/Prometheus/APC/HistogramTest.php b/tests/Test/Prometheus/APC/HistogramTest.php index 7ef2bed..777160d 100644 --- a/tests/Test/Prometheus/APC/HistogramTest.php +++ b/tests/Test/Prometheus/APC/HistogramTest.php @@ -11,7 +11,7 @@ */ class HistogramTest extends AbstractHistogramTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new APC(); $this->adapter->flushAPC(); diff --git a/tests/Test/Prometheus/AbstractCollectorRegistryTest.php b/tests/Test/Prometheus/AbstractCollectorRegistryTest.php index 76f3160..c0664cb 100644 --- a/tests/Test/Prometheus/AbstractCollectorRegistryTest.php +++ b/tests/Test/Prometheus/AbstractCollectorRegistryTest.php @@ -23,6 +23,8 @@ abstract class AbstractCollectorRegistryTest extends TestCase */ private $renderer; + abstract public function configureAdapter(): void; + public function setUp(): void { $this->configureAdapter(); @@ -32,7 +34,7 @@ public function setUp(): void /** * @test */ - public function itShouldSaveGauges() + public function itShouldSaveGauges(): void { $registry = new CollectorRegistry($this->adapter); @@ -63,7 +65,7 @@ public function itShouldSaveGauges() /** * @test */ - public function itShouldSaveCounters() + public function itShouldSaveCounters(): void { $registry = new CollectorRegistry($this->adapter); $metric = $registry->registerCounter('test', 'some_metric', 'this is for testing', ['foo', 'bar']); @@ -89,7 +91,7 @@ public function itShouldSaveCounters() /** * @test */ - public function itShouldSaveHistograms() + public function itShouldSaveHistograms(): void { $registry = new CollectorRegistry($this->adapter); $metric = $registry->registerHistogram( @@ -142,7 +144,7 @@ public function itShouldSaveHistograms() /** * @test */ - public function itShouldSaveHistogramsWithoutLabels() + public function itShouldSaveHistogramsWithoutLabels(): void { $registry = new CollectorRegistry($this->adapter); $metric = $registry->registerHistogram('test', 'some_metric', 'this is for testing'); @@ -183,7 +185,7 @@ public function itShouldSaveHistogramsWithoutLabels() /** * @test */ - public function itShouldIncreaseACounterWithoutNamespace() + public function itShouldIncreaseACounterWithoutNamespace(): void { $registry = new CollectorRegistry($this->adapter); $registry @@ -207,7 +209,7 @@ public function itShouldIncreaseACounterWithoutNamespace() /** * @test */ - public function itShouldForbidRegisteringTheSameCounterTwice() + public function itShouldForbidRegisteringTheSameCounterTwice(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerCounter('foo', 'metric', 'help'); @@ -219,7 +221,7 @@ public function itShouldForbidRegisteringTheSameCounterTwice() /** * @test */ - public function itShouldForbidRegisteringTheSameCounterWithDifferentLabels() + public function itShouldForbidRegisteringTheSameCounterWithDifferentLabels(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerCounter('foo', 'metric', 'help', ["foo", "bar"]); @@ -231,7 +233,7 @@ public function itShouldForbidRegisteringTheSameCounterWithDifferentLabels() /** * @test */ - public function itShouldForbidRegisteringTheSameHistogramTwice() + public function itShouldForbidRegisteringTheSameHistogramTwice(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerHistogram('foo', 'metric', 'help'); @@ -243,7 +245,7 @@ public function itShouldForbidRegisteringTheSameHistogramTwice() /** * @test */ - public function itShouldForbidRegisteringTheSameHistogramWithDifferentLabels() + public function itShouldForbidRegisteringTheSameHistogramWithDifferentLabels(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerCounter('foo', 'metric', 'help', ["foo", "bar"]); @@ -255,7 +257,7 @@ public function itShouldForbidRegisteringTheSameHistogramWithDifferentLabels() /** * @test */ - public function itShouldForbidRegisteringTheSameGaugeTwice() + public function itShouldForbidRegisteringTheSameGaugeTwice(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerGauge('foo', 'metric', 'help'); @@ -267,7 +269,7 @@ public function itShouldForbidRegisteringTheSameGaugeTwice() /** * @test */ - public function itShouldForbidRegisteringTheSameGaugeWithDifferentLabels() + public function itShouldForbidRegisteringTheSameGaugeWithDifferentLabels(): void { $registry = new CollectorRegistry($this->adapter); $registry->registerGauge('foo', 'metric', 'help', ["foo", "bar"]); @@ -279,7 +281,7 @@ public function itShouldForbidRegisteringTheSameGaugeWithDifferentLabels() /** * @test */ - public function itShouldThrowAnExceptionWhenGettingANonExistentMetric() + public function itShouldThrowAnExceptionWhenGettingANonExistentMetric(): void { $registry = new CollectorRegistry($this->adapter); @@ -290,7 +292,7 @@ public function itShouldThrowAnExceptionWhenGettingANonExistentMetric() /** * @test */ - public function itShouldNotRegisterACounterTwice() + public function itShouldNotRegisterACounterTwice(): void { $registry = new CollectorRegistry($this->adapter); $counterA = $registry->getOrRegisterCounter("foo", "bar", "Help text"); @@ -302,7 +304,7 @@ public function itShouldNotRegisterACounterTwice() /** * @test */ - public function itShouldNotRegisterAGaugeTwice() + public function itShouldNotRegisterAGaugeTwice(): void { $registry = new CollectorRegistry($this->adapter); $gaugeA = $registry->getOrRegisterGauge("foo", "bar", "Help text"); @@ -314,7 +316,7 @@ public function itShouldNotRegisterAGaugeTwice() /** * @test */ - public function itShouldNotRegisterAHistogramTwice() + public function itShouldNotRegisterAHistogramTwice(): void { $registry = new CollectorRegistry($this->adapter); $histogramA = $registry->getOrRegisterHistogram("foo", "bar", "Help text"); @@ -322,7 +324,4 @@ public function itShouldNotRegisterAHistogramTwice() $this->assertSame($histogramA, $histogramB); } - - - abstract public function configureAdapter(); } diff --git a/tests/Test/Prometheus/AbstractCounterTest.php b/tests/Test/Prometheus/AbstractCounterTest.php index a932939..1073a8f 100644 --- a/tests/Test/Prometheus/AbstractCounterTest.php +++ b/tests/Test/Prometheus/AbstractCounterTest.php @@ -19,17 +19,17 @@ abstract class AbstractCounterTest extends TestCase */ public $adapter; + abstract public function configureAdapter(): void; + public function setUp(): void { $this->configureAdapter(); } - abstract public function configureAdapter(); - /** * @test */ - public function itShouldIncreaseWithLabels() + public function itShouldIncreaseWithLabels(): void { $counter = new Counter($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $counter->inc(['lalal', 'lululu']); @@ -63,7 +63,7 @@ public function itShouldIncreaseWithLabels() /** * @test */ - public function itShouldIncreaseWithoutLabelWhenNoLabelsAreDefined() + public function itShouldIncreaseWithoutLabelWhenNoLabelsAreDefined(): void { $counter = new Counter($this->adapter, 'test', 'some_metric', 'this is for testing'); $counter->inc(); @@ -95,7 +95,7 @@ public function itShouldIncreaseWithoutLabelWhenNoLabelsAreDefined() /** * @test */ - public function itShouldIncreaseTheCounterByAnArbitraryInteger() + public function itShouldIncreaseTheCounterByAnArbitraryInteger(): void { $counter = new Counter($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $counter->inc(['lalal', 'lululu']); @@ -128,7 +128,7 @@ public function itShouldIncreaseTheCounterByAnArbitraryInteger() /** * @test */ - public function itShouldRejectInvalidMetricsNames() + public function itShouldRejectInvalidMetricsNames(): void { $this->expectException(InvalidArgumentException::class); new Counter($this->adapter, 'test', 'some metric invalid metric', 'help'); @@ -137,7 +137,7 @@ public function itShouldRejectInvalidMetricsNames() /** * @test */ - public function itShouldRejectInvalidLabelNames() + public function itShouldRejectInvalidLabelNames(): void { $this->expectException(InvalidArgumentException::class); new Counter($this->adapter, 'test', 'some_metric', 'help', ['invalid label']); @@ -149,7 +149,7 @@ public function itShouldRejectInvalidLabelNames() * * @param mixed $value The label value */ - public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value) + public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value): void { $label = 'foo'; $histogram = new Counter($this->adapter, 'test', 'some_metric', 'help', [$label]); @@ -177,7 +177,7 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v * @return array * @see isShouldAcceptArbitraryLabelValues */ - public function labelValuesDataProvider() + public function labelValuesDataProvider(): array { $cases = []; // Basic Latin diff --git a/tests/Test/Prometheus/AbstractGaugeTest.php b/tests/Test/Prometheus/AbstractGaugeTest.php index 393c087..138e772 100644 --- a/tests/Test/Prometheus/AbstractGaugeTest.php +++ b/tests/Test/Prometheus/AbstractGaugeTest.php @@ -19,17 +19,17 @@ abstract class AbstractGaugeTest extends TestCase */ public $adapter; + abstract public function configureAdapter(): void; + public function setUp(): void { $this->configureAdapter(); } - abstract public function configureAdapter(); - /** * @test */ - public function itShouldAllowSetWithLabels() + public function itShouldAllowSetWithLabels(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->set(123, ['lalal', 'lululu']); @@ -63,7 +63,7 @@ public function itShouldAllowSetWithLabels() /** * @test */ - public function itShouldAllowSetWithoutLabelWhenNoLabelsAreDefined() + public function itShouldAllowSetWithoutLabelWhenNoLabelsAreDefined(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing'); $gauge->set(123); @@ -97,7 +97,7 @@ public function itShouldAllowSetWithoutLabelWhenNoLabelsAreDefined() /** * @test */ - public function itShouldAllowSetWithAFloatValue() + public function itShouldAllowSetWithAFloatValue(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing'); $gauge->set(123.5); @@ -131,7 +131,7 @@ public function itShouldAllowSetWithAFloatValue() /** * @test */ - public function itShouldIncrementAValue() + public function itShouldIncrementAValue(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->inc(['lalal', 'lululu']); @@ -164,7 +164,7 @@ public function itShouldIncrementAValue() /** * @test */ - public function itShouldIncrementWithFloatValue() + public function itShouldIncrementWithFloatValue(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->inc(['lalal', 'lululu']); @@ -197,7 +197,7 @@ public function itShouldIncrementWithFloatValue() /** * @test */ - public function itShouldDecrementAValue() + public function itShouldDecrementAValue(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->dec(['lalal', 'lululu']); @@ -230,7 +230,7 @@ public function itShouldDecrementAValue() /** * @test */ - public function itShouldDecrementWithFloatValue() + public function itShouldDecrementWithFloatValue(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->dec(['lalal', 'lululu']); @@ -263,7 +263,7 @@ public function itShouldDecrementWithFloatValue() /** * @test */ - public function itShouldOverwriteWhenSettingTwice() + public function itShouldOverwriteWhenSettingTwice(): void { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', ['foo', 'bar']); $gauge->set(123, ['lalal', 'lululu']); @@ -296,7 +296,7 @@ public function itShouldOverwriteWhenSettingTwice() /** * @test */ - public function itShouldRejectInvalidMetricsNames() + public function itShouldRejectInvalidMetricsNames(): void { $this->expectException(InvalidArgumentException::class); new Gauge($this->adapter, 'test', 'some metric invalid metric', 'help'); @@ -305,7 +305,7 @@ public function itShouldRejectInvalidMetricsNames() /** * @test */ - public function itShouldRejectInvalidLabelNames() + public function itShouldRejectInvalidLabelNames(): void { $this->expectException(InvalidArgumentException::class); new Gauge($this->adapter, 'test', 'some_metric', 'help', ['invalid label']); @@ -317,7 +317,7 @@ public function itShouldRejectInvalidLabelNames() * * @param mixed $value The label value */ - public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value) + public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value): void { $label = 'foo'; $histogram = new Gauge($this->adapter, 'test', 'some_metric', 'help', [$label]); @@ -345,7 +345,7 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v * @return array * @see isShouldAcceptArbitraryLabelValues */ - public function labelValuesDataProvider() + public function labelValuesDataProvider(): array { $cases = []; // Basic Latin diff --git a/tests/Test/Prometheus/AbstractHistogramTest.php b/tests/Test/Prometheus/AbstractHistogramTest.php index d5f9ebb..324849f 100644 --- a/tests/Test/Prometheus/AbstractHistogramTest.php +++ b/tests/Test/Prometheus/AbstractHistogramTest.php @@ -19,17 +19,17 @@ abstract class AbstractHistogramTest extends TestCase */ public $adapter; + abstract public function configureAdapter(): void; + public function setUp(): void { $this->configureAdapter(); } - abstract public function configureAdapter(); - /** * @test */ - public function itShouldObserveWithLabels() + public function itShouldObserveWithLabels(): void { $histogram = new Histogram( $this->adapter, @@ -99,7 +99,7 @@ public function itShouldObserveWithLabels() /** * @test */ - public function itShouldObserveWithoutLabelWhenNoLabelsAreDefined() + public function itShouldObserveWithoutLabelWhenNoLabelsAreDefined(): void { $histogram = new Histogram( $this->adapter, @@ -168,7 +168,7 @@ public function itShouldObserveWithoutLabelWhenNoLabelsAreDefined() /** * @test */ - public function itShouldObserveValuesOfTypeDouble() + public function itShouldObserveValuesOfTypeDouble(): void { $histogram = new Histogram( $this->adapter, @@ -238,7 +238,7 @@ public function itShouldObserveValuesOfTypeDouble() /** * @test */ - public function itShouldProvideDefaultBuckets() + public function itShouldProvideDefaultBuckets(): void { // .005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, 2.5, 5.0, 7.5, 10.0 @@ -375,7 +375,7 @@ public function itShouldProvideDefaultBuckets() /** * @test */ - public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing() + public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Histogram buckets must be in increasing order'); @@ -385,7 +385,7 @@ public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing() /** * @test */ - public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket() + public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Histogram must have at least one bucket'); @@ -395,7 +395,7 @@ public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket() /** * @test */ - public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe() + public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Histogram cannot have a label named'); @@ -405,7 +405,7 @@ public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe() /** * @test */ - public function itShouldRejectInvalidMetricsNames() + public function itShouldRejectInvalidMetricsNames(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid metric name'); @@ -415,7 +415,7 @@ public function itShouldRejectInvalidMetricsNames() /** * @test */ - public function itShouldRejectInvalidLabelNames() + public function itShouldRejectInvalidLabelNames(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Invalid label name'); @@ -428,7 +428,7 @@ public function itShouldRejectInvalidLabelNames() * * @param mixed $value The label value */ - public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value) + public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($value): void { $label = 'foo'; $histogram = new Histogram($this->adapter, 'test', 'some_metric', 'help', [$label], [1]); @@ -455,7 +455,7 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v /** * @test */ - public function itShouldBeAbleToGenerateExponentialBucketsGivenSpecificBounds() + public function itShouldBeAbleToGenerateExponentialBucketsGivenSpecificBounds(): void { $start = 0.05; $growthFactor = 1.5; @@ -487,7 +487,7 @@ public function itShouldBeAbleToGenerateExponentialBucketsGivenSpecificBounds() * @return array * @see isShouldAcceptArbitraryLabelValues */ - public function labelValuesDataProvider() + public function labelValuesDataProvider(): array { $cases = []; // Basic Latin diff --git a/tests/Test/Prometheus/InMemory/CollectorRegistryTest.php b/tests/Test/Prometheus/InMemory/CollectorRegistryTest.php index 5e6b9c7..aea9b42 100644 --- a/tests/Test/Prometheus/InMemory/CollectorRegistryTest.php +++ b/tests/Test/Prometheus/InMemory/CollectorRegistryTest.php @@ -7,7 +7,7 @@ class CollectorRegistryTest extends AbstractCollectorRegistryTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new InMemory(); $this->adapter->flushMemory(); diff --git a/tests/Test/Prometheus/InMemory/CounterTest.php b/tests/Test/Prometheus/InMemory/CounterTest.php index b2176d8..9f47b7a 100644 --- a/tests/Test/Prometheus/InMemory/CounterTest.php +++ b/tests/Test/Prometheus/InMemory/CounterTest.php @@ -10,8 +10,7 @@ */ class CounterTest extends AbstractCounterTest { - - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new InMemory(); $this->adapter->flushMemory(); diff --git a/tests/Test/Prometheus/InMemory/GaugeTest.php b/tests/Test/Prometheus/InMemory/GaugeTest.php index 84210b6..8397868 100644 --- a/tests/Test/Prometheus/InMemory/GaugeTest.php +++ b/tests/Test/Prometheus/InMemory/GaugeTest.php @@ -10,8 +10,7 @@ */ class GaugeTest extends AbstractGaugeTest { - - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new InMemory(); $this->adapter->flushMemory(); diff --git a/tests/Test/Prometheus/InMemory/HistogramTest.php b/tests/Test/Prometheus/InMemory/HistogramTest.php index 50d402d..8e3cff5 100644 --- a/tests/Test/Prometheus/InMemory/HistogramTest.php +++ b/tests/Test/Prometheus/InMemory/HistogramTest.php @@ -10,8 +10,7 @@ */ class HistogramTest extends AbstractHistogramTest { - - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new InMemory(); $this->adapter->flushMemory(); diff --git a/tests/Test/Prometheus/Redis/CollectorRegistryTest.php b/tests/Test/Prometheus/Redis/CollectorRegistryTest.php index fbf53b9..b2b0899 100644 --- a/tests/Test/Prometheus/Redis/CollectorRegistryTest.php +++ b/tests/Test/Prometheus/Redis/CollectorRegistryTest.php @@ -10,7 +10,7 @@ */ class CollectorRegistryTest extends AbstractCollectorRegistryTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new Redis(['host' => REDIS_HOST]); $this->adapter->flushRedis(); diff --git a/tests/Test/Prometheus/Redis/CounterTest.php b/tests/Test/Prometheus/Redis/CounterTest.php index 4aea278..cf858eb 100644 --- a/tests/Test/Prometheus/Redis/CounterTest.php +++ b/tests/Test/Prometheus/Redis/CounterTest.php @@ -11,7 +11,7 @@ */ class CounterTest extends AbstractCounterTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new Redis(['host' => REDIS_HOST]); $this->adapter->flushRedis(); diff --git a/tests/Test/Prometheus/Redis/CounterWithPrefixTest.php b/tests/Test/Prometheus/Redis/CounterWithPrefixTest.php index 0409140..b578049 100644 --- a/tests/Test/Prometheus/Redis/CounterWithPrefixTest.php +++ b/tests/Test/Prometheus/Redis/CounterWithPrefixTest.php @@ -11,7 +11,7 @@ */ class CounterWithPrefixTest extends AbstractCounterTest { - public function configureAdapter() + public function configureAdapter(): void { $connection = new \Redis(); $connection->connect(REDIS_HOST); diff --git a/tests/Test/Prometheus/Redis/GaugeTest.php b/tests/Test/Prometheus/Redis/GaugeTest.php index 6ffd300..c5dfbe6 100644 --- a/tests/Test/Prometheus/Redis/GaugeTest.php +++ b/tests/Test/Prometheus/Redis/GaugeTest.php @@ -11,7 +11,7 @@ */ class GaugeTest extends AbstractGaugeTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new Redis(['host' => REDIS_HOST]); $this->adapter->flushRedis(); diff --git a/tests/Test/Prometheus/Redis/GaugeWithPrefixTest.php b/tests/Test/Prometheus/Redis/GaugeWithPrefixTest.php index 1ba4d0e..4a33d68 100644 --- a/tests/Test/Prometheus/Redis/GaugeWithPrefixTest.php +++ b/tests/Test/Prometheus/Redis/GaugeWithPrefixTest.php @@ -11,7 +11,7 @@ */ class GaugeWithPrefixTest extends AbstractGaugeTest { - public function configureAdapter() + public function configureAdapter(): void { $connection = new \Redis(); $connection->connect(REDIS_HOST); diff --git a/tests/Test/Prometheus/Redis/HistogramTest.php b/tests/Test/Prometheus/Redis/HistogramTest.php index 40fd314..3939853 100644 --- a/tests/Test/Prometheus/Redis/HistogramTest.php +++ b/tests/Test/Prometheus/Redis/HistogramTest.php @@ -11,7 +11,7 @@ */ class HistogramTest extends AbstractHistogramTest { - public function configureAdapter() + public function configureAdapter(): void { $this->adapter = new Redis(['host' => REDIS_HOST]); $this->adapter->flushRedis(); diff --git a/tests/Test/Prometheus/Redis/HistogramWithPrefixTest.php b/tests/Test/Prometheus/Redis/HistogramWithPrefixTest.php index 4c25388..dc2bded 100644 --- a/tests/Test/Prometheus/Redis/HistogramWithPrefixTest.php +++ b/tests/Test/Prometheus/Redis/HistogramWithPrefixTest.php @@ -11,7 +11,7 @@ */ class HistogramWithPrefixTest extends AbstractHistogramTest { - public function configureAdapter() + public function configureAdapter(): void { $connection = new \Redis(); $connection->connect(REDIS_HOST); diff --git a/tests/Test/Prometheus/Storage/RedisTest.php b/tests/Test/Prometheus/Storage/RedisTest.php index 9f2df78..fdf842e 100644 --- a/tests/Test/Prometheus/Storage/RedisTest.php +++ b/tests/Test/Prometheus/Storage/RedisTest.php @@ -13,7 +13,7 @@ class RedisTest extends TestCase /** * @test */ - public function itShouldThrowAnExceptionOnConnectionFailure() + public function itShouldThrowAnExceptionOnConnectionFailure(): void { $redis = new Redis(['host' => '/dev/null']); @@ -27,7 +27,7 @@ public function itShouldThrowAnExceptionOnConnectionFailure() /** * @test */ - public function itShouldThrowExceptionWhenInjectedRedisIsNotConnected() + public function itShouldThrowExceptionWhenInjectedRedisIsNotConnected(): void { $connection = new \Redis();