Skip to content

Commit 2e48b1f

Browse files
jderussenicolas-grekas
authored andcommitted
Remove constraint for PHP < 8
1 parent 4b52758 commit 2e48b1f

File tree

2 files changed

+6
-38
lines changed

2 files changed

+6
-38
lines changed

NumberFormatter/NumberFormatter.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,7 @@ public function format($value, int $type = self::TYPE_DEFAULT)
356356
{
357357
// The original NumberFormatter does not support this format type
358358
if (self::TYPE_CURRENCY === $type) {
359-
if (\PHP_VERSION_ID >= 80000) {
360-
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%s given).', $type));
361-
}
362-
363-
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
364-
365-
return false;
359+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%s given).', $type));
366360
}
367361

368362
if (self::CURRENCY === $this->style) {
@@ -514,13 +508,7 @@ public function parseCurrency(string $value, string &$currency, int &$position =
514508
public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$position = 0)
515509
{
516510
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
517-
if (\PHP_VERSION_ID >= 80000) {
518-
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%d given).', $type));
519-
}
520-
521-
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
522-
523-
return false;
511+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%d given).', $type));
524512
}
525513

526514
// Any invalid number at the end of the string is removed.

Tests/NumberFormatter/AbstractNumberFormatterTest.php

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,7 @@ public function formatTypeDoubleWithCurrencyStyleProvider()
326326
*/
327327
public function testFormatTypeCurrency($formatter, $value)
328328
{
329-
if (\PHP_VERSION_ID >= 80000) {
330-
$this->expectException(\ValueError::class);
331-
} elseif (method_exists($this, 'expectWarning')) {
332-
$this->expectWarning();
333-
} else {
334-
$this->expectException(Warning::class);
335-
}
329+
$this->expectException(\ValueError::class);
336330

337331
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
338332
}
@@ -342,9 +336,7 @@ public function testFormatTypeCurrency($formatter, $value)
342336
*/
343337
public function testFormatTypeCurrencyReturn($formatter, $value)
344338
{
345-
if (\PHP_VERSION_ID >= 80000) {
346-
$this->expectException(\ValueError::class);
347-
}
339+
$this->expectException(\ValueError::class);
348340

349341
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
350342
}
@@ -705,13 +697,7 @@ public function parseProvider()
705697

706698
public function testParseTypeDefault()
707699
{
708-
if (\PHP_VERSION_ID >= 80000) {
709-
$this->expectException(\ValueError::class);
710-
} elseif (method_exists($this, 'expectWarning')) {
711-
$this->expectWarning();
712-
} else {
713-
$this->expectException(Warning::class);
714-
}
700+
$this->expectException(\ValueError::class);
715701

716702
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
717703
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
@@ -831,13 +817,7 @@ public function parseTypeDoubleProvider()
831817

832818
public function testParseTypeCurrency()
833819
{
834-
if (\PHP_VERSION_ID >= 80000) {
835-
$this->expectException(\ValueError::class);
836-
} elseif (method_exists($this, 'expectWarning')) {
837-
$this->expectWarning();
838-
} else {
839-
$this->expectException(Warning::class);
840-
}
820+
$this->expectException(\ValueError::class);
841821

842822
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
843823
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);

0 commit comments

Comments
 (0)