@@ -28,7 +28,7 @@ class LocaleConfig
2828 /**
2929 * The configured route action that holds a route's locale.
3030 *
31- * @var string
31+ * @var string|null
3232 */
3333 protected $ routeAction ;
3434
@@ -37,7 +37,7 @@ class LocaleConfig
3737 *
3838 * @param array $config
3939 */
40- public function __construct ($ config = [])
40+ public function __construct (array $ config = [])
4141 {
4242 $ this ->supportedLocales = $ config ['supported_locales ' ] ?? [];
4343 $ this ->omittedLocale = $ config ['omitted_locale ' ] ?? null ;
@@ -50,7 +50,7 @@ public function __construct($config = [])
5050 *
5151 * @return array
5252 */
53- public function getSupportedLocales ()
53+ public function getSupportedLocales (): array
5454 {
5555 return $ this ->supportedLocales ;
5656 }
@@ -62,7 +62,7 @@ public function getSupportedLocales()
6262 *
6363 * @return void
6464 */
65- public function setSupportedLocales ($ locales )
65+ public function setSupportedLocales (array $ locales ): void
6666 {
6767 $ this ->supportedLocales = $ locales ;
6868 }
@@ -72,7 +72,7 @@ public function setSupportedLocales($locales)
7272 *
7373 * @return string|null
7474 */
75- public function getOmittedLocale ()
75+ public function getOmittedLocale (): ? string
7676 {
7777 return $ this ->omittedLocale ;
7878 }
@@ -84,7 +84,7 @@ public function getOmittedLocale()
8484 *
8585 * @return void
8686 */
87- public function setOmittedLocale ($ locale )
87+ public function setOmittedLocale (? string $ locale ): void
8888 {
8989 $ this ->omittedLocale = $ locale ;
9090 }
@@ -94,7 +94,7 @@ public function setOmittedLocale($locale)
9494 *
9595 * @return string|null
9696 */
97- public function getFallbackLocale ()
97+ public function getFallbackLocale (): ? string
9898 {
9999 return $ this ->fallbackLocale ;
100100 }
@@ -106,39 +106,39 @@ public function getFallbackLocale()
106106 *
107107 * @return void
108108 */
109- public function setFallbackLocale ($ locale )
109+ public function setFallbackLocale (? string $ locale ): void
110110 {
111111 $ this ->fallbackLocale = $ locale ;
112112 }
113113
114114 /**
115115 * Get the route action that holds a route's locale.
116116 *
117- * @return string
117+ * @return string|null
118118 */
119- public function getRouteAction ()
119+ public function getRouteAction (): ? string
120120 {
121121 return $ this ->routeAction ;
122122 }
123123
124124 /**
125125 * Set the route action that holds a route's locale.
126126 *
127- * @param string $locale
127+ * @param string $action
128128 *
129129 * @return string
130130 */
131- public function setRouteAction ($ locale )
131+ public function setRouteAction (string $ action ): string
132132 {
133- return $ this ->routeAction = $ locale ;
133+ return $ this ->routeAction = $ action ;
134134 }
135135
136136 /**
137137 * Get the locales (not the slugs or domains).
138138 *
139139 * @return array
140140 */
141- public function getLocales ()
141+ public function getLocales (): array
142142 {
143143 $ locales = $ this ->getSupportedLocales ();
144144
@@ -156,7 +156,7 @@ public function getLocales()
156156 *
157157 * @return string|null
158158 */
159- public function findSlugByLocale ($ locale )
159+ public function findSlugByLocale (string $ locale ): ? string
160160 {
161161 if ( ! $ this ->isSupportedLocale ($ locale ) || $ this ->hasCustomDomains ()) {
162162 return null ;
@@ -172,7 +172,7 @@ public function findSlugByLocale($locale)
172172 *
173173 * @return string|null
174174 */
175- public function findDomainByLocale ($ locale )
175+ public function findDomainByLocale (string $ locale ): ? string
176176 {
177177 if ( ! $ this ->isSupportedLocale ($ locale ) || ! $ this ->hasCustomDomains ()) {
178178 return null ;
@@ -188,7 +188,7 @@ public function findDomainByLocale($locale)
188188 *
189189 * @return string|null
190190 */
191- public function findLocaleBySlug ($ slug )
191+ public function findLocaleBySlug (string $ slug ): ? string
192192 {
193193 if ($ this ->hasCustomDomains ()) {
194194 return null ;
@@ -208,7 +208,7 @@ public function findLocaleBySlug($slug)
208208 *
209209 * @return string|null
210210 */
211- public function findLocaleByDomain ($ domain )
211+ public function findLocaleByDomain (string $ domain ): ? string
212212 {
213213 if ( ! $ this ->hasCustomDomains ()) {
214214 return null ;
@@ -222,7 +222,7 @@ public function findLocaleByDomain($domain)
222222 *
223223 * @return bool
224224 */
225- public function hasLocales ()
225+ public function hasLocales (): bool
226226 {
227227 return count ($ this ->getSupportedLocales ()) > 0 ;
228228 }
@@ -233,7 +233,7 @@ public function hasLocales()
233233 *
234234 * @return bool
235235 */
236- public function hasSimpleLocales ()
236+ public function hasSimpleLocales (): bool
237237 {
238238 return is_numeric (key ($ this ->getSupportedLocales ()));
239239 }
@@ -243,7 +243,7 @@ public function hasSimpleLocales()
243243 *
244244 * @return bool
245245 */
246- public function hasCustomSlugs ()
246+ public function hasCustomSlugs (): bool
247247 {
248248 return $ this ->hasLocales () && ! $ this ->hasSimpleLocales () && ! $ this ->hasCustomDomains ();
249249 }
@@ -253,7 +253,7 @@ public function hasCustomSlugs()
253253 *
254254 * @return bool
255255 */
256- public function hasCustomDomains ()
256+ public function hasCustomDomains (): bool
257257 {
258258 $ firstValue = array_values ($ this ->getSupportedLocales ())[0 ] ?? '' ;
259259 $ containsDot = strpos ($ firstValue , '. ' ) !== false ;
@@ -264,11 +264,11 @@ public function hasCustomDomains()
264264 /**
265265 * Check if the given locale is supported.
266266 *
267- * @param string $locale
267+ * @param string|null $locale
268268 *
269269 * @return bool
270270 */
271- public function isSupportedLocale ($ locale )
271+ public function isSupportedLocale (? string $ locale ): bool
272272 {
273273 return in_array ($ locale , $ this ->getLocales ());
274274 }
0 commit comments