diff --git a/composer.json b/composer.json index f2f8b90..5f8aaf8 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "jimdo/prometheus_client_php": "*" }, "require": { - "php": "^7.2", + "php": "^7.2||^8.0", "ext-json": "*", "guzzlehttp/guzzle": "^6.3", "symfony/polyfill-apcu": "^1.6" diff --git a/src/Prometheus/RenderTextFormat.php b/src/Prometheus/RenderTextFormat.php index a5b78dc..a314a60 100644 --- a/src/Prometheus/RenderTextFormat.php +++ b/src/Prometheus/RenderTextFormat.php @@ -56,9 +56,9 @@ private function renderSample(MetricFamilySamples $metric, Sample $sample): stri */ private function escapeLabelValue($v): string { - $v = str_replace("\\", "\\\\", $v); - $v = str_replace("\n", "\\n", $v); - $v = str_replace("\"", "\\\"", $v); + $v = str_replace("\\", "\\\\", $v ? (string)$v : ''); + $v = str_replace("\n", "\\n", $v ? (string)$v : ''); + $v = str_replace("\"", "\\\"", $v ? (string)$v : ''); return $v; } }