Skip to content

Commit cf0e5c9

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: [Intl] promote warnings to value errors on PHP 8 Fix CS DateTime validator support for trailing data
2 parents 5a01f0e + 0f14185 commit cf0e5c9

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

NumberFormatter/NumberFormatter.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,10 @@ public function format($value, $type = self::TYPE_DEFAULT)
357357

358358
// The original NumberFormatter does not support this format type
359359
if (self::TYPE_CURRENCY === $type) {
360+
if (\PHP_VERSION_ID >= 80000) {
361+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%s given).', $type));
362+
}
363+
360364
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
361365

362366
return false;
@@ -513,6 +517,10 @@ public function parse($value, $type = self::TYPE_DOUBLE, &$position = 0)
513517
$type = (int) $type;
514518

515519
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
520+
if (\PHP_VERSION_ID >= 80000) {
521+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%d given).', $type));
522+
}
523+
516524
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
517525

518526
return false;

Tests/NumberFormatter/AbstractNumberFormatterTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,9 @@ public function formatTypeDoubleWithCurrencyStyleProvider()
324324
*/
325325
public function testFormatTypeCurrency($formatter, $value)
326326
{
327-
if (method_exists($this, 'expectWarning')) {
327+
if (\PHP_VERSION_ID >= 80000) {
328+
$this->expectException(\ValueError::class);
329+
} elseif (method_exists($this, 'expectWarning')) {
328330
$this->expectWarning();
329331
} else {
330332
$this->expectException(Warning::class);
@@ -338,6 +340,10 @@ public function testFormatTypeCurrency($formatter, $value)
338340
*/
339341
public function testFormatTypeCurrencyReturn($formatter, $value)
340342
{
343+
if (\PHP_VERSION_ID >= 80000) {
344+
$this->expectException(\ValueError::class);
345+
}
346+
341347
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
342348
}
343349

@@ -709,7 +715,9 @@ public function parseProvider()
709715

710716
public function testParseTypeDefault()
711717
{
712-
if (method_exists($this, 'expectWarning')) {
718+
if (\PHP_VERSION_ID >= 80000) {
719+
$this->expectException(\ValueError::class);
720+
} elseif (method_exists($this, 'expectWarning')) {
713721
$this->expectWarning();
714722
} else {
715723
$this->expectException(Warning::class);
@@ -833,7 +841,9 @@ public function parseTypeDoubleProvider()
833841

834842
public function testParseTypeCurrency()
835843
{
836-
if (method_exists($this, 'expectWarning')) {
844+
if (\PHP_VERSION_ID >= 80000) {
845+
$this->expectException(\ValueError::class);
846+
} elseif (method_exists($this, 'expectWarning')) {
837847
$this->expectWarning();
838848
} else {
839849
$this->expectException(Warning::class);

0 commit comments

Comments
 (0)