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 89f423f

Browse filesBrowse files
bug #31744 [Validator] Fix TimezoneValidator default option (ro0NL)
This PR was squashed before being merged into the 4.3 branch (closes #31744). Discussion ---------- [Validator] Fix TimezoneValidator default option | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/roadmap): - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against branch 4.4. - Legacy code removals go to the master branch. --> Commits ------- ee71cdb [Validator] Fix TimezoneValidator default option
2 parents d38c19a + ee71cdb commit 89f423f
Copy full SHA for 89f423f

File tree

Expand file treeCollapse file tree

4 files changed

+11
-27
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+11
-27
lines changed

‎src/Symfony/Component/Validator/Constraints/Timezone.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/Timezone.php
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Timezone extends Constraint
4343
/**
4444
* {@inheritdoc}
4545
*/
46-
public function __construct(array $options = null)
46+
public function __construct($options = null)
4747
{
4848
parent::__construct($options);
4949

@@ -58,4 +58,12 @@ public function __construct(array $options = null)
5858
throw new ConstraintDefinitionException('The option "intlCompatible" can only be used when the PHP intl extension is available.');
5959
}
6060
}
61+
62+
/**
63+
* {@inheritdoc}
64+
*/
65+
public function getDefaultOption()
66+
{
67+
return 'zone';
68+
}
6169
}

‎src/Symfony/Component/Validator/Constraints/TimezoneValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/TimezoneValidator.php
-22Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,6 @@ public function validate($value, Constraint $constraint)
7575
->addViolation();
7676
}
7777

78-
/**
79-
* {@inheritdoc}
80-
*/
81-
public function getDefaultOption()
82-
{
83-
return 'zone';
84-
}
85-
86-
/**
87-
* {@inheritdoc}
88-
*/
89-
protected function formatValue($value, $format = 0)
90-
{
91-
$value = parent::formatValue($value, $format);
92-
93-
if (!$value || \DateTimeZone::PER_COUNTRY === $value) {
94-
return $value;
95-
}
96-
97-
return array_search($value, (new \ReflectionClass(\DateTimeZone::class))->getConstants(), true) ?: $value;
98-
}
99-
10078
private static function getPhpTimezones(int $zone, string $countryCode = null): array
10179
{
10280
if (null !== $countryCode) {

‎src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/TimezoneTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function testValidTimezoneConstraints()
2323
{
2424
new Timezone();
2525
new Timezone(['zone' => \DateTimeZone::ALL]);
26-
new Timezone(['zone' => \DateTimeZone::ALL_WITH_BC]);
26+
new Timezone(\DateTimeZone::ALL_WITH_BC);
2727
new Timezone([
2828
'zone' => \DateTimeZone::PER_COUNTRY,
2929
'countryCode' => 'AR',

‎src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/TimezoneValidatorTest.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ public function testGroupedTimezonesWithInvalidCountry()
267267
*/
268268
public function testDeprecatedTimezonesAreValidWithBC(string $timezone)
269269
{
270-
$constraint = new Timezone([
271-
'zone' => \DateTimeZone::ALL_WITH_BC,
272-
]);
270+
$constraint = new Timezone(\DateTimeZone::ALL_WITH_BC);
273271

274272
$this->validator->validate($timezone, $constraint);
275273

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.