Browse Source

Merge pull request #16251 from cakephp/issue-16250

Fix type error on PHP 8.
Mark Story 4 years ago
parent
commit
0f4a248ef0
2 changed files with 5 additions and 1 deletions
  1. 1 1
      src/I18n/Number.php
  2. 4 0
      tests/TestCase/I18n/NumberTest.php

+ 1 - 1
src/I18n/Number.php

@@ -95,7 +95,7 @@ class Number
     {
         $formatter = static::formatter(['precision' => $precision, 'places' => $precision] + $options);
 
-        return $formatter->format($value);
+        return $formatter->format((float)$value);
     }
 
     /**

+ 4 - 0
tests/TestCase/I18n/NumberTest.php

@@ -489,6 +489,10 @@ class NumberTest extends TestCase
         $result = $this->Number->toPercentage(0.13, 0, ['locale' => 'fi_FI', 'multiply' => true]);
         $expected = '13 %';
         $this->assertSame($expected, $result);
+
+        $result = $this->Number->toPercentage('0.13', 0, ['locale' => 'fi_FI', 'multiply' => true]);
+        $expected = '13 %';
+        $this->assertSame($expected, $result);
     }
 
     /**