Skip to content

Commit 1bdae34

Browse files
committed
Merge branch '5.1' into master
* 5.1: [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 80e5a7f + 41cb27b commit 1bdae34

File tree

8 files changed

+37
-14
lines changed

8 files changed

+37
-14
lines changed

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function doAsk(OutputInterface $output, Question $question)
112112

113113
if (\function_exists('sapi_windows_cp_set')) {
114114
// Codepage used by cmd.exe on Windows to allow special characters (éàüñ).
115-
sapi_windows_cp_set(1252);
115+
@sapi_windows_cp_set(1252);
116116
}
117117

118118
if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ class ArgvInput extends Input
4545

4646
public function __construct(array $argv = null, InputDefinition $definition = null)
4747
{
48-
if (null === $argv) {
49-
$argv = $_SERVER['argv'];
50-
}
48+
$argv = $argv ?? $_SERVER['argv'] ?? [];
5149

5250
// strip the application name
5351
array_shift($argv);

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ public function testCookieOptions()
194194

195195
public function testSessionOptions()
196196
{
197-
if (\defined('HHVM_VERSION')) {
198-
$this->markTestSkipped('HHVM is not handled in this test case.');
199-
}
200-
201197
$options = [
202198
'url_rewriter.tags' => 'a=href',
203199
'cache_expire' => '200',

src/Symfony/Component/Intl/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;

src/Symfony/Component/Intl/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);

src/Symfony/Component/Validator/Constraints/DateTimeValidator.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ public function validate($value, Constraint $constraint)
5353
return;
5454
}
5555

56+
if ('+' === substr($constraint->format, -1)) {
57+
$errors['warnings'] = array_filter($errors['warnings'], function ($warning) {
58+
return 'Trailing data' !== $warning;
59+
});
60+
}
61+
5662
foreach ($errors['warnings'] as $warning) {
5763
if ('The parsed date was invalid' === $warning) {
5864
$this->context->buildViolation($constraint->message)

src/Symfony/Component/Validator/Tests/Constraints/DateTimeValidatorTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,12 @@ public function getInvalidDateTimes()
114114
['Y-m-d H:i:s', '2010-01-01 00:00:60', DateTime::INVALID_TIME_ERROR],
115115
];
116116
}
117+
118+
public function testDateTimeWithTrailingData()
119+
{
120+
$this->validator->validate('1995-05-10 00:00:00', new DateTime([
121+
'format' => 'Y-m-d+',
122+
]));
123+
$this->assertNoViolation();
124+
}
117125
}

src/Symfony/Component/VarDumper/Tests/Caster/ReflectionCasterTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ public function testClosureCaster()
8484

8585
public function testFromCallableClosureCaster()
8686
{
87-
if (\defined('HHVM_VERSION_ID')) {
88-
$this->markTestSkipped('Not for HHVM.');
89-
}
9087
$var = [
9188
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
9289
(new \ReflectionMethod(__CLASS__, 'stub'))->getClosure(),

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy