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
This commit is contained in:
commit
41cb27beb0
@ -112,7 +112,7 @@ class QuestionHelper extends Helper
|
|||||||
|
|
||||||
if (\function_exists('sapi_windows_cp_set')) {
|
if (\function_exists('sapi_windows_cp_set')) {
|
||||||
// Codepage used by cmd.exe on Windows to allow special characters (éàüñ).
|
// Codepage used by cmd.exe on Windows to allow special characters (éàüñ).
|
||||||
sapi_windows_cp_set(1252);
|
@sapi_windows_cp_set(1252);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
|
if (null === $autocomplete || !self::$stty || !Terminal::hasSttyAvailable()) {
|
||||||
|
@ -45,9 +45,7 @@ class ArgvInput extends Input
|
|||||||
|
|
||||||
public function __construct(array $argv = null, InputDefinition $definition = null)
|
public function __construct(array $argv = null, InputDefinition $definition = null)
|
||||||
{
|
{
|
||||||
if (null === $argv) {
|
$argv = $argv ?? $_SERVER['argv'] ?? [];
|
||||||
$argv = $_SERVER['argv'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// strip the application name
|
// strip the application name
|
||||||
array_shift($argv);
|
array_shift($argv);
|
||||||
|
@ -194,10 +194,6 @@ class NativeSessionStorageTest extends TestCase
|
|||||||
|
|
||||||
public function testSessionOptions()
|
public function testSessionOptions()
|
||||||
{
|
{
|
||||||
if (\defined('HHVM_VERSION')) {
|
|
||||||
$this->markTestSkipped('HHVM is not handled in this test case.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'url_rewriter.tags' => 'a=href',
|
'url_rewriter.tags' => 'a=href',
|
||||||
'cache_expire' => '200',
|
'cache_expire' => '200',
|
||||||
|
@ -354,6 +354,10 @@ abstract class NumberFormatter
|
|||||||
{
|
{
|
||||||
// The original NumberFormatter does not support this format type
|
// The original NumberFormatter does not support this format type
|
||||||
if (self::TYPE_CURRENCY === $type) {
|
if (self::TYPE_CURRENCY === $type) {
|
||||||
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%s given).', $type));
|
||||||
|
}
|
||||||
|
|
||||||
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -508,6 +512,10 @@ abstract class NumberFormatter
|
|||||||
public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$position = 0)
|
public function parse(string $value, int $type = self::TYPE_DOUBLE, int &$position = 0)
|
||||||
{
|
{
|
||||||
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
|
if (self::TYPE_DEFAULT === $type || self::TYPE_CURRENCY === $type) {
|
||||||
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
throw new \ValueError(sprintf('The format type must be a NumberFormatter::TYPE_* constant (%d given).', $type));
|
||||||
|
}
|
||||||
|
|
||||||
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
trigger_error(__METHOD__.'(): Unsupported format type '.$type, \E_USER_WARNING);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -324,7 +324,9 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeCurrency($formatter, $value)
|
public function testFormatTypeCurrency($formatter, $value)
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectWarning')) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
$this->expectException(\ValueError::class);
|
||||||
|
} elseif (method_exists($this, 'expectWarning')) {
|
||||||
$this->expectWarning();
|
$this->expectWarning();
|
||||||
} else {
|
} else {
|
||||||
$this->expectException(Warning::class);
|
$this->expectException(Warning::class);
|
||||||
@ -338,6 +340,10 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeCurrencyReturn($formatter, $value)
|
public function testFormatTypeCurrencyReturn($formatter, $value)
|
||||||
{
|
{
|
||||||
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
$this->expectException(\ValueError::class);
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
|
$this->assertFalse(@$formatter->format($value, NumberFormatter::TYPE_CURRENCY));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +705,9 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
|
|
||||||
public function testParseTypeDefault()
|
public function testParseTypeDefault()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectWarning')) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
$this->expectException(\ValueError::class);
|
||||||
|
} elseif (method_exists($this, 'expectWarning')) {
|
||||||
$this->expectWarning();
|
$this->expectWarning();
|
||||||
} else {
|
} else {
|
||||||
$this->expectException(Warning::class);
|
$this->expectException(Warning::class);
|
||||||
@ -823,7 +831,9 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
|
|
||||||
public function testParseTypeCurrency()
|
public function testParseTypeCurrency()
|
||||||
{
|
{
|
||||||
if (method_exists($this, 'expectWarning')) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
|
$this->expectException(\ValueError::class);
|
||||||
|
} elseif (method_exists($this, 'expectWarning')) {
|
||||||
$this->expectWarning();
|
$this->expectWarning();
|
||||||
} else {
|
} else {
|
||||||
$this->expectException(Warning::class);
|
$this->expectException(Warning::class);
|
||||||
|
@ -53,6 +53,12 @@ class DateTimeValidator extends DateValidator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ('+' === substr($constraint->format, -1)) {
|
||||||
|
$errors['warnings'] = array_filter($errors['warnings'], function ($warning) {
|
||||||
|
return 'Trailing data' !== $warning;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($errors['warnings'] as $warning) {
|
foreach ($errors['warnings'] as $warning) {
|
||||||
if ('The parsed date was invalid' === $warning) {
|
if ('The parsed date was invalid' === $warning) {
|
||||||
$this->context->buildViolation($constraint->message)
|
$this->context->buildViolation($constraint->message)
|
||||||
|
@ -114,4 +114,12 @@ class DateTimeValidatorTest extends ConstraintValidatorTestCase
|
|||||||
['Y-m-d H:i:s', '2010-01-01 00:00:60', DateTime::INVALID_TIME_ERROR],
|
['Y-m-d H:i:s', '2010-01-01 00:00:60', DateTime::INVALID_TIME_ERROR],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDateTimeWithTrailingData()
|
||||||
|
{
|
||||||
|
$this->validator->validate('1995-05-10 00:00:00', new DateTime([
|
||||||
|
'format' => 'Y-m-d+',
|
||||||
|
]));
|
||||||
|
$this->assertNoViolation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,9 +84,6 @@ EOTXT
|
|||||||
|
|
||||||
public function testFromCallableClosureCaster()
|
public function testFromCallableClosureCaster()
|
||||||
{
|
{
|
||||||
if (\defined('HHVM_VERSION_ID')) {
|
|
||||||
$this->markTestSkipped('Not for HHVM.');
|
|
||||||
}
|
|
||||||
$var = [
|
$var = [
|
||||||
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
|
(new \ReflectionMethod($this, __FUNCTION__))->getClosure($this),
|
||||||
(new \ReflectionMethod(__CLASS__, 'stub'))->getClosure(),
|
(new \ReflectionMethod(__CLASS__, 'stub'))->getClosure(),
|
||||||
|
Reference in New Issue
Block a user