From 504d75eea5015ffe989306f0b6072b0a34d97a6a Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Mon, 13 Jul 2026 22:55:09 -0700 Subject: [PATCH 1/2] Fix PHP 8 number formatting compatibility --- lib/WeatherMap.functions.php | 7 ++++--- tests/Unit/FormatNumberTest.php | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 tests/Unit/FormatNumberTest.php diff --git a/lib/WeatherMap.functions.php b/lib/WeatherMap.functions.php index 90ef0c6..3aa5d5c 100644 --- a/lib/WeatherMap.functions.php +++ b/lib/WeatherMap.functions.php @@ -1640,11 +1640,12 @@ function format_number($number, $precision = 2, $trailing_zeroes = 0) { $sign = -1; } - $number = round($number, $precision); + $number = (string) round($number, $precision); $integer = intval($number); + $integer_string = (string) $integer; - if (strlen($integer) < strlen($number)) { - $decimal = substr($number, strlen($integer) + 1); + if (strlen($integer_string) < strlen($number)) { + $decimal = substr($number, strlen($integer_string) + 1); } $decimal ??= ''; diff --git a/tests/Unit/FormatNumberTest.php b/tests/Unit/FormatNumberTest.php new file mode 100644 index 0000000..1e3e4ab --- /dev/null +++ b/tests/Unit/FormatNumberTest.php @@ -0,0 +1,16 @@ +toBe('12.35'); + }); + + it('formats whole numbers without a decimal suffix', function (): void { + expect(format_number(12.0, 2))->toBe(12); + }); +}); From 686277c364808a3da9e10b8c0d5048dbcace89cf Mon Sep 17 00:00:00 2001 From: Thomas Vincent Date: Mon, 13 Jul 2026 23:03:04 -0700 Subject: [PATCH 2/2] Fix Weathermap integration dependencies --- .github/workflows/plugin-ci-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugin-ci-workflow.yml b/.github/workflows/plugin-ci-workflow.yml index e806000..02b1688 100644 --- a/.github/workflows/plugin-ci-workflow.yml +++ b/.github/workflows/plugin-ci-workflow.yml @@ -85,7 +85,7 @@ jobs: run: sudo apt-get update - name: Install System Dependencies - run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping libapache2-mod-php${{ matrix.php }} + run: sudo apt-get install -y apache2 snmp snmpd rrdtool fping - name: Start SNMPD Agent and Test run: |