Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update validation messages
  • Loading branch information
phansys committed Nov 29, 2018
commit de788025e1e26f728c6177e1bdc68c593e8ca4d2
22 changes: 9 additions & 13 deletions src/Symfony/Component/Validator/Constraints/TimezoneValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,16 @@ public function getDefaultOption()
*/
private function formatExtraInfo($zone, $countryCode = null)
{
if (!$zone) {
return '';
}
$r = new \ReflectionClass('\DateTimeZone');
$consts = $r->getConstants();

if (!$value = array_search($zone, $consts, true)) {
$value = $zone;
}

$value = ' for "'.$value.'" zone';

if ($countryCode) {
$value = ' for ISO 3166-1 country code '.$countryCode;
$value = ' for ISO 3166-1 country code "'.$countryCode.'"';
} else {
$r = new \ReflectionClass('\DateTimeZone');
$consts = $r->getConstants();
if ($value = array_search($zone, $consts, true)) {
$value = ' for "'.$value.'" zone';
} else {
$value = ' for zone with identifier '.$zone;
}
}

return $this->formatValue($value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getInvalidGroupedTimezones()
array('America/Barbados', \DateTimeZone::ANTARCTICA, ' for "ANTARCTICA" zone'),
array('Europe/Kiev', \DateTimeZone::ARCTIC, ' for "ARCTIC" zone'),
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN, ' for "INDIAN" zone'),
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA, ' for "260" zone'),
array('Asia/Ho_Chi_Minh', \DateTimeZone::INDIAN | \DateTimeZone::ANTARCTICA, ' for zone with identifier 260'),
);
}

Expand Down Expand Up @@ -214,8 +214,8 @@ public function testInvalidGroupedTimezonesByCountry($timezone, $what, $country,
public function getInvalidGroupedTimezonesByCountry()
{
return array(
array('America/Argentina/Cordoba', \DateTimeZone::PER_COUNTRY, 'FR', ' for ISO 3166-1 country code FR'),
array('America/Barbados', \DateTimeZone::PER_COUNTRY, 'PT', ' for ISO 3166-1 country code PT'),
array('America/Argentina/Cordoba', \DateTimeZone::PER_COUNTRY, 'FR', ' for ISO 3166-1 country code "FR"'),
array('America/Barbados', \DateTimeZone::PER_COUNTRY, 'PT', ' for ISO 3166-1 country code "PT"'),
);
}
}