Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81b954b

Browse filesBrowse files
committed
minor #38120 [Intl] promote warnings to value errors on PHP 8 (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [Intl] promote warnings to value errors on PHP 8 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | Commits ------- 82d9d41 [Intl] promote warnings to value errors on PHP 8
2 parents 799624b + 82d9d41 commit 81b954b
Copy full SHA for 81b954b

File tree

Expand file treeCollapse file tree

2 files changed

+21
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+21
-3
lines changed

‎src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/NumberFormatter/NumberFormatter.php
+8Lines 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;

‎src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Intl/Tests/NumberFormatter/AbstractNumberFormatterTest.php
+13-3Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.