Skip to content

Commit b47c316

Browse files
authored
Allow Symfony 5.x components to be used (#31)
1 parent a9908bc commit b47c316

3 files changed

Lines changed: 19 additions & 35 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
include:
19-
- { php-version: 7.2, symfony-locked-version: none, dependency-version: prefer-lowest }
20-
- { php-version: 7.4, symfony-locked-version: 4.4.*, dependency-version: prefer-stable }
19+
- { php-version: 7.4, symfony-locked-version: none, dependency-version: prefer-lowest }
20+
- { php-version: 7.4, symfony-locked-version: none, dependency-version: prefer-stable }
2121
- { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-stable }
2222
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
2323
steps:

composer.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@
2020
}
2121
],
2222
"require": {
23-
"php": "^7.2 | 8.0.* | 8.1.*",
23+
"php": "^7.4 | 8.0.* | 8.1.*",
2424
"ext-intl": "*",
2525
"lib-icu": ">=4.8",
2626
"jms/parser-lib": "^1.0.0",
2727
"psr/log": "^1.0",
28-
"symfony/config": "^3.4.31|^4.0",
29-
"symfony/dependency-injection": "^3.4.31|^4.0",
30-
"symfony/finder": "^3.4.31|^4.0",
31-
"symfony/framework-bundle": "^4.4",
32-
"symfony/http-kernel": "^3.4.31|^4.0",
33-
"symfony/translation": "^4.2",
34-
"symfony/translation-contracts": "^1.0.2|^2.0|^3.0",
28+
"symfony/config": "^4.3|^5.0",
29+
"symfony/dependency-injection": "^4.4|^5.0",
30+
"symfony/finder": "^3.4.31|^4.0|^5.0",
31+
"symfony/framework-bundle": "^4.4|^5.0",
32+
"symfony/http-kernel": "^4.4|^5.0",
33+
"symfony/translation": "^4.2|^5.0",
34+
"symfony/translation-contracts": "^2.0|^3.0",
3535
"twig/twig": "^1.42|^2.0|^3.0"
3636
},
3737
"require-dev": {
3838
"phpunit/phpunit": "^8.5 | ^9.0",
39-
"symfony/monolog-bundle": "^3.4.31|^4.0",
40-
"symfony/phpunit-bridge": "> 5.0",
41-
"symfony/twig-bundle": "^3.4.31|^4.0",
42-
"symfony/yaml": "^4.4"
39+
"symfony/monolog-bundle": "^3.4.31",
40+
"symfony/phpunit-bridge": ">= 5.0",
41+
"symfony/twig-bundle": "^3.4.31|^4.0|^5.0",
42+
"symfony/yaml": "^4.4|^5.0"
4343
},
4444
"autoload": {
4545
"psr-4": {

src/Translator/FormatterDecorator.php

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Symfony\Contracts\Translation\LocaleAwareInterface;
66
use Symfony\Contracts\Translation\TranslatorInterface;
77
use Webfactory\IcuTranslationBundle\Translator\Formatting\FormatterInterface;
8-
use Webfactory\IcuTranslationBundle\Translator\Formatting\IntlFormatter;
98

109
/**
1110
* Decorates a Symfony translator and adds support for message formatting.
@@ -15,16 +14,14 @@ class FormatterDecorator implements TranslatorInterface, LocaleAwareInterface
1514
/**
1615
* The inner translator.
1716
*
18-
* @var TranslatorInterface
17+
* @var TranslatorInterface&LocaleAwareInterface
1918
*/
20-
protected $translator;
19+
protected TranslatorInterface $translator;
2120

2221
/**
2322
* The formatter that is used to apply message transformations.
24-
*
25-
* @var IntlFormatter
2623
*/
27-
protected $formatter;
24+
protected FormatterInterface $formatter;
2825

2926
public function __construct(TranslatorInterface $translator, FormatterInterface $formatter)
3027
{
@@ -36,27 +33,14 @@ public function __construct(TranslatorInterface $translator, FormatterInterface
3633
$this->formatter = $formatter;
3734
}
3835

39-
/**
40-
* Translates the given message.
41-
*
42-
* @param string $id The message id
43-
* @param array $parameters An array of parameters for the message
44-
* @param string $domain The domain for the message
45-
* @param string $locale The locale
46-
*/
47-
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
36+
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
4837
{
4938
$message = $this->translator->trans($id, $parameters, $domain, $locale);
5039

5140
return $this->handleFormatting($id, $message, $parameters, $locale);
5241
}
5342

54-
/**
55-
* Sets the current locale.
56-
*
57-
* @param string $locale The locale
58-
*/
59-
public function setLocale($locale)
43+
public function setLocale(string $locale): void
6044
{
6145
$this->translator->setLocale($locale);
6246
}

0 commit comments

Comments
 (0)