bug #38283 [Translator] Optional Intl dependency (ro0NL)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

[Translator] Optional Intl dependency

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #38279
| 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/releases):
 - Always add tests and ensure they pass.
 - Never break backward compatibility (see https://symfony.com/bc).
 - 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 master.
-->

i decided to cast $locale at construct, given its property is documented to be string

Commits
-------

a2eb263457 [Translator] Optional Intl dependency
This commit is contained in:
Fabien Potencier 2020-09-24 11:40:07 +02:00
commit d9bcb64fc0

View File

@ -163,7 +163,7 @@ class Translator implements LegacyTranslatorInterface, TranslatorInterface, Tran
}
$this->assertValidLocale($locale);
$this->locale = $locale;
$this->locale = $locale ?? (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
}
/**
@ -171,7 +171,7 @@ class Translator implements LegacyTranslatorInterface, TranslatorInterface, Tran
*/
public function getLocale()
{
return $this->locale ?? \Locale::getDefault();
return $this->locale;
}
/**