Skip to content

Commit 2834d3b

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Intl] promote warnings to value errors on PHP 8 Fix CS DateTime validator support for trailing data Remove some leftover for HHVM support Simplify code Fix tests on 5.6 [Debug] Skip a test that was meant for HHVM. [Console] Silence warnings on sapi_windows_cp_set() call guard $argv + $token against null, preventing unnecessary exceptions
2 parents 842d092 + cf0e5c9 commit 2834d3b

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
@@ -354,6 +354,10 @@ public function format($value, int $type = self::TYPE_DEFAULT)
354354
{
355355
// The original NumberFormatter does not support this format type
356356
if (self::TYPE_CURRENCY === $type) {
357+
if (\PHP_VERSION_ID >= 80000) {
358+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%s given).', $type));
359+
}
360+
357361
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
358362

359363
return false;
@@ -508,6 +512,10 @@ public function parseCurrency(string $value, string &$currency, int &$position =
508512
public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$position = 0)
509513
{
510514
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
515+
if (\PHP_VERSION_ID >= 80000) {
516+
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%d given).', $type));
517+
}
518+
511519
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
512520

513521
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

@@ -699,7 +705,9 @@ public function parseProvider()
699705

700706
public function testParseTypeDefault()
701707
{
702-
if (method_exists($this, 'expectWarning')) {
708+
if (\PHP_VERSION_ID >= 80000) {
709+
$this->expectException(\ValueError::class);
710+
} elseif (method_exists($this, 'expectWarning')) {
703711
$this->expectWarning();
704712
} else {
705713
$this->expectException(Warning::class);
@@ -823,7 +831,9 @@ public function parseTypeDoubleProvider()
823831

824832
public function testParseTypeCurrency()
825833
{
826-
if (method_exists($this, 'expectWarning')) {
834+
if (\PHP_VERSION_ID >= 80000) {
835+
$this->expectException(\ValueError::class);
836+
} elseif (method_exists($this, 'expectWarning')) {
827837
$this->expectWarning();
828838
} else {
829839
$this->expectException(Warning::class);

0 commit comments

Comments
 (0)