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)
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