8000 [Validator] Class "Locale" not found · Issue #54833 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Validator] Class "Locale" not found #54833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
deasraze opened this issue May 3, 2024 · 1 comment
Closed

[Validator] Class "Locale" not found #54833

deasraze opened this issue May 3, 2024 · 1 comment

Comments

@deasraze
Copy link
deasraze commented May 3, 2024

Symfony version(s) affected

7.0.7 or lower

Description

The symfony/validator package offers the ConstraintValidatorTestCase class to simplify testing of custom constraints. It includes a default locale override using the Locale class provided by the intl extension:
https://github.com/symfony/validator/blob/0edd0a59dfb8766d49cba51aa31af8287e05ccba/Test/ConstraintValidatorTestCase.php#L85-L86
And restores the locale back to its default state:
https://github.com/symfony/validator/blob/0edd0a59dfb8766d49cba51aa31af8287e05ccba/Test/ConstraintValidatorTestCase.php#L98
However, the symfony/validator package does not explicitly require the intl extension or the symfony/polyfill-intl-icu package. This leads to an error if the ConstraintValidatorTestCase class is used without the extension or polyfill being installed:

Error: Class "Locale" not found
/app/vendor/symfony/validator/Test/ConstraintValidatorTestCase.php:85

How to reproduce

Create a test class that extends ConstraintValidatorTestCase and includes the test method. In this scenario, ensure that neither the intl extension nor the polyfill package is installed.

Possible Solution

We won't need to override the Default locale if the \Locale class doesn't exist or we need adding warning/error, that say require an explicit dependency of Locale to improve DX.

Additional Context

No response

@alexandre-daubois
Copy link
Member

Seems like a bug indeed, #54834 should fix it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0