@@ -26,23 +26,20 @@ final class CatalogueManager
2626 /**
2727 * @var MessageCatalogueInterface[]
2828 */
29- private $ catalogues ;
29+ private $ catalogues = [] ;
3030
3131 /**
3232 * @param MessageCatalogueInterface[] $catalogues
3333 */
34- public function load (array $ catalogues )
34+ public function load (array $ catalogues ): void
3535 {
3636 $ this ->catalogues = [];
3737 foreach ($ catalogues as $ c ) {
3838 $ this ->catalogues [$ c ->getLocale ()] = $ c ;
3939 }
4040 }
4141
42- /**
43- * @return array
44- */
45- public function getDomains ()
42+ public function getDomains (): array
4643 {
4744 /** @var MessageCatalogueInterface $c */
4845 $ c = \reset ($ this ->catalogues );
@@ -51,12 +48,9 @@ public function getDomains()
5148 }
5249
5350 /**
54- * @param string $locale
55- * @param string $domain
56- *
5751 * @return CatalogueMessage[]
5852 */
59- public function getMessages ($ locale , $ domain )
53+ public function getMessages (string $ locale , string $ domain ): array
6054 {
6155 $ messages = [];
6256 if (!isset ($ this ->catalogues [$ locale ])) {
@@ -82,12 +76,12 @@ public function getMessages($locale, $domain)
8276 *
8377 * @return CatalogueMessage[]
8478 */
85- public function findMessages (array $ config = [])
79+ public function findMessages (array $ config = []): array
8680 {
87- $ inputDomain = isset ( $ config ['domain ' ]) ? $ config [ ' domain ' ] : null ;
88- $ isNew = isset ( $ config ['isNew ' ]) ? $ config [ ' isNew ' ] : null ;
89- $ isObsolete = isset ( $ config ['isObsolete ' ]) ? $ config [ ' isObsolete ' ] : null ;
90- $ isApproved = isset ( $ config ['isApproved ' ]) ? $ config [ ' isApproved ' ] : null ;
81+ $ inputDomain = $ config ['domain ' ] ?? null ;
82+ $ isNew = $ config ['isNew ' ] ?? null ;
83+ $ isObsolete = $ config ['isObsolete ' ] ?? null ;
84+ $ isApproved = $ config ['isApproved ' ] ?? null ;
9185
9286 $ messages = [];
9387 $ catalogues = [];
@@ -112,7 +106,7 @@ public function findMessages(array $config = [])
112106 }
113107 }
114108
115- $ messages = \array_filter ($ messages , function (CatalogueMessage $ m ) use ($ isNew , $ isObsolete , $ isApproved ) {
109+ $ messages = \array_filter ($ messages , static function (CatalogueMessage $ m ) use ($ isNew , $ isObsolete , $ isApproved ) {
116110 if (null !== $ isNew && $ m ->isNew () !== $ isNew ) {
117111 return false ;
118112 }
@@ -132,10 +126,8 @@ public function findMessages(array $config = [])
132126 /**
133127 * @param string $domain
134128 * @param string $key
135- *
136- * @return array
137129 */
138- public function getTranslations ($ domain , $ key )
130+ public function getTranslations ($ domain , $ key ): array
139131 {
140132 $ translations = [];
141133 foreach ($ this ->catalogues as $ locale => $ catalogue ) {
@@ -147,15 +139,7 @@ public function getTranslations($domain, $key)
147139 return $ translations ;
148140 }
149141
150- /**
151- * @param $locale
152- * @param $domain
153- * @param $key
154- * @param $text
155- *
156- * @return CatalogueMessage
157- */
158- private function createMessage (MessageCatalogueInterface $ catalogue , $ locale , $ domain , $ key , $ text )
142+ private function createMessage (MessageCatalogueInterface $ catalogue , string $ locale , string $ domain , string $ key , string $ text ): CatalogueMessage
159143 {
160144 $ catalogueMessage = new CatalogueMessage ($ this , $ locale , $ domain , $ key , $ text );
161145
0 commit comments