8000 bug #54834 [Validator] Check `Locale` class existence before using it… · symfony/symfony@ca66c1c · GitHub
[go: up one dir, main page]

Skip to content

Commit ca66c1c

Browse files
committed
bug #54834 [Validator] Check Locale class existence before using it (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- [Validator] Check `Locale` class existence before using it | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #54833 | License | MIT Commits ------- 2c845fa [Validator] Check `Locale` class existence before using it
2 parents 52099f9 + 2c845fa commit ca66c1c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ protected function setUp(): void
8080
$this->validator = $this->createValidator();
8181
$this->validator->initialize($this->context);
8282

83-
$this->defaultLocale = \Locale::getDefault();
84-
\Locale::setDefault('en');
83+
if (class_exists(\Locale::class)) {
84+
$this->defaultLocale = \Locale::getDefault();
85+
\Locale::setDefault('en');
86+
}
8587

8688
$this->expectedViolations = [];
8789
$this->call = 0;
@@ -93,7 +95,9 @@ protected function tearDown(): void
9395
{
9496
$this->restoreDefaultTimezone();
9597

96-
\Locale::setDefault($this->defaultLocale);
98+
if (class_exists(\Locale::class)) {
99+
\Locale::setDefault($this->defaultLocale);
100+
}
97101
}
98102

99103
protected function setDefaultTimezone(?string $defaultTimezone)

0 commit comments

Comments
 (0)
0