|
24 | 24 | use JMS\TranslationBundle\Model\FileSource; |
25 | 25 | use JMS\TranslationBundle\Model\Message\XliffMessage; |
26 | 26 | use JMS\TranslationBundle\Model\MessageCatalogue; |
| 27 | +use JMS\TranslationBundle\Model\SourceInterface; |
27 | 28 |
|
28 | 29 | /** |
29 | 30 | * XLIFF dumper. |
|
36 | 37 | */ |
37 | 38 | class XliffDumper implements DumperInterface |
38 | 39 | { |
39 | | - /** |
40 | | - * @var string |
41 | | - */ |
42 | | - private $sourceLanguage = 'en'; |
| 40 | + private string $sourceLanguage = 'en'; |
43 | 41 |
|
44 | | - /** |
45 | | - * @var bool |
46 | | - */ |
47 | | - private $addDate = true; |
| 42 | + private bool $addDate = true; |
48 | 43 |
|
49 | | - /** |
50 | | - * @var bool |
51 | | - */ |
52 | | - private $addReference = true; |
| 44 | + private bool $addReference = true; |
53 | 45 |
|
54 | | - /** |
55 | | - * @var bool |
56 | | - */ |
57 | | - private $addReferencePosition = true; |
| 46 | + private bool $addReferencePosition = true; |
58 | 47 |
|
59 | | - public function setAddDate($bool) |
| 48 | + public function setAddDate(bool $bool): static |
60 | 49 | { |
61 | | - $this->addDate = (bool) $bool; |
| 50 | + $this->addDate = $bool; |
| 51 | + |
| 52 | + return $this; |
62 | 53 | } |
63 | 54 |
|
64 | | - public function setSourceLanguage($lang) |
| 55 | + public function setSourceLanguage(string $lang): static |
65 | 56 | { |
66 | 57 | $this->sourceLanguage = $lang; |
| 58 | + |
| 59 | + return $this; |
67 | 60 | } |
68 | 61 |
|
69 | | - public function setAddReference($bool) |
| 62 | + public function setAddReference(bool $bool): static |
70 | 63 | { |
71 | 64 | $this->addReference = $bool; |
| 65 | + |
| 66 | + return $this; |
72 | 67 | } |
73 | 68 |
|
74 | | - public function setAddReferencePosition($bool) |
| 69 | + public function setAddReferencePosition(bool $bool): static |
75 | 70 | { |
76 | 71 | $this->addReferencePosition = $bool; |
| 72 | + |
| 73 | + return $this; |
77 | 74 | } |
78 | 75 |
|
79 | | - /** |
80 | | - * @param MessageCatalogue $catalogue |
81 | | - * @param MessageCatalogue|string $domain |
82 | | - * |
83 | | - * @return string |
84 | | - */ |
85 | | - public function dump(MessageCatalogue $catalogue, $domain = 'messages') |
| 76 | + public function dump(MessageCatalogue $catalogue, string $domain = 'messages'): string |
86 | 77 | { |
87 | 78 | $doc = new \DOMDocument('1.0', 'utf-8'); |
88 | 79 | $doc->formatOutput = true; |
@@ -199,13 +190,13 @@ public function dump(MessageCatalogue $catalogue, $domain = 'messages') |
199 | 190 |
|
200 | 191 | /** |
201 | 192 | * Sort the sources by path-line-column |
202 | | - * If the reference position are not used, the reference file will be write once |
| 193 | + * If the reference position are not used, the reference file will be written once |
203 | 194 | * |
204 | | - * @param array $sources |
| 195 | + * @param SourceInterface[] $sources |
205 | 196 | * |
206 | | - * @return array |
| 197 | + * @return array<string, SourceInterface[]> |
207 | 198 | */ |
208 | | - protected function getSortedSources(array $sources) |
| 199 | + protected function getSortedSources(array $sources): array |
209 | 200 | { |
210 | 201 | $indexedSources = []; |
211 | 202 | foreach ($sources as $source) { |
|
0 commit comments