1 | <?php |
||
25 | class FileStorage implements Storage |
||
26 | { |
||
27 | /** |
||
28 | * @var TranslationWriter |
||
29 | */ |
||
30 | private $writer; |
||
31 | |||
32 | /** |
||
33 | * @var TranslationLoader |
||
34 | */ |
||
35 | private $loader; |
||
36 | |||
37 | /** |
||
38 | * @var string directory path |
||
39 | */ |
||
40 | private $dir; |
||
41 | |||
42 | /** |
||
43 | * @var MessageCatalogue[] Fetched catalogies |
||
44 | */ |
||
45 | private $catalogues; |
||
46 | |||
47 | /** |
||
48 | * @param TranslationWriter $writer |
||
49 | * @param TranslationLoader $loader |
||
50 | * @param array $dir |
||
51 | */ |
||
52 | public function __construct(TranslationWriter $writer, TranslationLoader $loader, $dir) |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function get($locale, $domain, $key) |
||
63 | { |
||
64 | $catalogue = $this->getCatalogue($locale); |
||
65 | |||
66 | $translation = $catalogue->get($key, $domain); |
||
67 | |||
68 | return new Message($key, $domain, $locale, $translation); |
||
69 | } |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function update(Message $message) |
||
75 | { |
||
76 | $catalogue = $this->getCatalogue($message->getLocale()); |
||
77 | $catalogue->set($message->getKey(), $message->getTranslation(), $message->getDomain()); |
||
78 | $this->writeCatalogue($catalogue, $message->getLocale(), $message->getDomain()); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | public function delete($locale, $domain, $key) |
||
93 | |||
94 | /** |
||
95 | * Save catalogue back to file. |
||
96 | * |
||
97 | * @param MessageCatalogue $catalogue |
||
98 | * @param string $domain |
||
99 | */ |
||
100 | private function writeCatalogue(MessageCatalogue $catalogue, $locale, $domain) |
||
110 | |||
111 | /** |
||
112 | * @param $locale |
||
113 | */ |
||
114 | private function getCatalogue($locale) |
||
122 | |||
123 | /** |
||
124 | * Load catalogue from files. |
||
125 | * |
||
126 | * @param $locale |
||
127 | * @param array $dirs |
||
128 | */ |
||
129 | private function loadCatalogue($locale, array $dirs) |
||
140 | } |
||
141 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..