[Web] Update composer libs

- Removing symfony/deprecation-contracts (v2.4.0)
  - Upgrading ddeboer/imap (1.12.1 => 1.13.1)
  - Upgrading directorytree/ldaprecord (v2.6.3 => v2.10.1)
  - Upgrading illuminate/contracts (v8.53.1 => v9.3.0)
  - Upgrading nesbot/carbon (2.51.1 => 2.57.0)
  - Upgrading phpmailer/phpmailer (v6.5.0 => v6.6.0)
  - Upgrading psr/container (1.1.1 => 2.0.2)
  - Upgrading psr/log (1.1.4 => 3.0.0)
  - Upgrading psr/simple-cache (1.0.1 => 2.0.0)
  - Upgrading robthree/twofactorauth (1.8.0 => 1.8.1)
  - Upgrading symfony/polyfill-ctype (v1.23.0 => v1.24.0)
  - Upgrading symfony/polyfill-mbstring (v1.23.1 => v1.24.0)
  - Upgrading symfony/polyfill-php80 (v1.23.1 => v1.24.0)
  - Upgrading symfony/translation (v5.3.4 => v6.0.5)
  - Upgrading symfony/translation-contracts (v2.4.0 => v3.0.0)
  - Upgrading symfony/var-dumper (v5.3.6 => v6.0.5)
  - Upgrading tightenco/collect (v8.34.0 => v8.83.2)
  - Upgrading twig/twig (v3.3.2 => v3.3.8)
This commit is contained in:
andryyy
2022-03-02 20:08:24 +01:00
parent 24275ffdbf
commit 98bc947d00
940 changed files with 7649 additions and 14226 deletions

View File

@@ -16,16 +16,12 @@ interface LocaleAwareInterface
/**
* Sets the current locale.
*
* @param string $locale The locale
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function setLocale(string $locale);
/**
* Returns the current locale.
*
* @return string The locale
*/
public function getLocale();
public function getLocale(): string;
}

View File

@@ -30,7 +30,20 @@ use Symfony\Contracts\Translation\TranslatorTrait;
*/
class TranslatorTest extends TestCase
{
public function getTranslator()
private $defaultLocale;
protected function setUp(): void
{
$this->defaultLocale = \Locale::getDefault();
\Locale::setDefault('en');
}
protected function tearDown(): void
{
\Locale::setDefault($this->defaultLocale);
}
public function getTranslator(): TranslatorInterface
{
return new class() implements TranslatorInterface {
use TranslatorTrait;
@@ -53,7 +66,6 @@ class TranslatorTest extends TestCase
public function testTransChoiceWithExplicitLocale($expected, $id, $number)
{
$translator = $this->getTranslator();
$translator->setLocale('en');
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
}
@@ -65,17 +77,25 @@ class TranslatorTest extends TestCase
*/
public function testTransChoiceWithDefaultLocale($expected, $id, $number)
{
\Locale::setDefault('en');
$translator = $this->getTranslator();
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
}
/**
* @dataProvider getTransChoiceTests
*/
public function testTransChoiceWithEnUsPosix($expected, $id, $number)
{
$translator = $this->getTranslator();
$translator->setLocale('en_US_POSIX');
$this->assertEquals($expected, $translator->trans($id, ['%count%' => $number]));
}
public function testGetSetLocale()
{
$translator = $this->getTranslator();
$translator->setLocale('en');
$this->assertEquals('en', $translator->getLocale());
}
@@ -294,14 +314,12 @@ class TranslatorTest extends TestCase
* This array should contain all currently known langcodes.
*
* As it is impossible to have this ever complete we should try as hard as possible to have it almost complete.
*
* @return array
*/
public function successLangcodes()
public function successLangcodes(): array
{
return [
['1', ['ay', 'bo', 'cgg', 'dz', 'id', 'ja', 'jbo', 'ka', 'kk', 'km', 'ko', 'ky']],
['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM']],
['2', ['nl', 'fr', 'en', 'de', 'de_GE', 'hy', 'hy_AM', 'en_US_POSIX']],
['3', ['be', 'bs', 'cs', 'hr']],
['4', ['cy', 'mt', 'sl']],
['6', ['ar']],
@@ -316,7 +334,7 @@ class TranslatorTest extends TestCase
*
* @return array with nplural together with langcodes
*/
public function failingLangcodes()
public function failingLangcodes(): array
{
return [
['1', ['fa']],
@@ -330,11 +348,10 @@ class TranslatorTest extends TestCase
/**
* We validate only on the plural coverage. Thus the real rules is not tested.
*
* @param string $nplural Plural expected
* @param array $matrix Containing langcodes and their plural index values
* @param bool $expectSuccess
* @param string $nplural Plural expected
* @param array $matrix Containing langcodes and their plural index values
*/
protected function validateMatrix($nplural, $matrix, $expectSuccess = true)
protected function validateMatrix(string $nplural, array $matrix, bool $expectSuccess = true)
{
foreach ($matrix as $langCode => $data) {
$indexes = array_flip($data);

View File

@@ -13,8 +13,6 @@ namespace Symfony\Contracts\Translation;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @method string getLocale() Returns the default locale
*/
interface TranslatorInterface
{
@@ -59,9 +57,12 @@ interface TranslatorInterface
* @param string|null $domain The domain for the message or null to use the default
* @param string|null $locale The locale or null to use the default
*
* @return string The translated string
*
* @throws \InvalidArgumentException If the locale contains invalid characters
*/
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null);
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string;
/**
* Returns the default locale.
*/
public function getLocale(): string;
}

View File

@@ -20,7 +20,7 @@ use Symfony\Component\Translation\Exception\InvalidArgumentException;
*/
trait TranslatorTrait
{
private $locale;
private ?string $locale = null;
/**
* {@inheritdoc}
@@ -32,10 +32,8 @@ trait TranslatorTrait
/**
* {@inheritdoc}
*
* @return string
*/
public function getLocale()
public function getLocale(): string
{
return $this->locale ?: (class_exists(\Locale::class) ? \Locale::getDefault() : 'en');
}
@@ -142,7 +140,7 @@ EOF;
{
$number = abs($number);
switch ('pt_BR' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
switch ('pt_BR' !== $locale && 'en_US_POSIX' !== $locale && \strlen($locale) > 3 ? substr($locale, 0, strrpos($locale, '_')) : $locale) {
case 'af':
case 'bn':
case 'bg':
@@ -151,6 +149,7 @@ EOF;
case 'de':
case 'el':
case 'en':
case 'en_US_POSIX':
case 'eo':
case 'es':
case 'et':

View File

@@ -16,7 +16,7 @@
}
],
"require": {
"php": ">=7.2.5"
"php": ">=8.0.2"
},
"suggest": {
"symfony/translation-implementation": ""
@@ -27,7 +27,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
"dev-main": "2.4-dev"
"dev-main": "3.0-dev"
},
"thanks": {
"name": "symfony/contracts",