diff --git a/src/plugins/BasePlugin.php b/src/plugins/BasePlugin.php index 285d30b..7cf2c7b 100644 --- a/src/plugins/BasePlugin.php +++ b/src/plugins/BasePlugin.php @@ -31,44 +31,44 @@ abstract public function gettext(string $msgId): string; /** * Get translation for a message id * - * @param mixed $msgId Message id + * @param string $msgId Message id * @return string */ - abstract public function __($msgId): string; + abstract public function __(string $msgId): string; /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $domain Domain + * @param string $msgctxt msgctxt + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - abstract public function dnpgettext($domain, $msgctxt, $msgId, $msgIdPlural, $number): string; + abstract public function dnpgettext(string $domain, string $msgctxt, string $msgId, string $msgIdPlural, int $number): string; /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $domain Domain + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - abstract public function dngettext($domain, $msgId, $msgIdPlural, $number): string; + abstract public function dngettext(string $domain, string $msgId, string $msgIdPlural, int $number): string; /** * Get translation * - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $msgctxt msgctxt + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - abstract public function npgettext($msgctxt, $msgId, $msgIdPlural, $number): string; + abstract public function npgettext(string $msgctxt, string $msgId, string $msgIdPlural, int $number): string; /** * Plural version of gettext @@ -83,29 +83,29 @@ abstract public function ngettext(string $msgId, string $msgIdPlural, int $numbe /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id + * @param string $domain Domain + * @param string $msgctxt msgctxt + * @param string $msgId Message id * @return string */ - abstract public function dpgettext($domain, $msgctxt, $msgId): string; + abstract public function dpgettext(string $domain, string $msgctxt, string $msgId): string; /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgId Message id + * @param string $domain Domain + * @param string $msgId Message id * @return string */ - abstract public function dgettext($domain, $msgId): string; + abstract public function dgettext(string $domain, string $msgId): string; /** * Get translation * - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id + * @param string $msgctxt msgctxt + * @param string $msgId Message id * @return string */ - abstract public function pgettext($msgctxt, $msgId): string; + abstract public function pgettext(string $msgctxt, string $msgId): string; } diff --git a/src/plugins/MoReader.php b/src/plugins/MoReader.php index 2471bb8..86fe791 100644 --- a/src/plugins/MoReader.php +++ b/src/plugins/MoReader.php @@ -250,10 +250,10 @@ public static function readInteger(int $endian, $res) /** * Return string id or translation * - * @param mixed $msgId The message id + * @param string $msgId The message id * @return string */ - public function idOrFind($msgId): string + public function idOrFind(string $msgId): string { if (array_key_exists($msgId, $this->data->translations)) { return $this->data->translations[$msgId]; @@ -265,10 +265,10 @@ public function idOrFind($msgId): string /** * Get translation for a message id * - * @param mixed $msgId Message id + * @param string $msgId Message id * @return string */ - public function __($msgId): string + public function __(string $msgId): string { return self::gettext($msgId); } @@ -287,14 +287,14 @@ public function gettext(string $msgId): string /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $domain Domain + * @param string $msgctxt msgctxt + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - public function dnpgettext($domain, $msgctxt, $msgId, $msgIdPlural, $number): string + public function dnpgettext(string $domain, string $msgctxt, string $msgId, string $msgIdPlural, int $number): string { return self::idOrFind($msgId); } @@ -302,13 +302,13 @@ public function dnpgettext($domain, $msgctxt, $msgId, $msgIdPlural, $number): st /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $domain Domain + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - public function dngettext($domain, $msgId, $msgIdPlural, $number): string + public function dngettext(string $domain, string $msgId, string $msgIdPlural, int $number): string { return self::idOrFind($msgId); } @@ -316,15 +316,19 @@ public function dngettext($domain, $msgId, $msgIdPlural, $number): string /** * Get translation * - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id - * @param mixed $msgIdPlural Plural message id - * @param mixed $number Number + * @param string $msgctxt msgctxt + * @param string $msgId Message id + * @param string $msgIdPlural Plural message id + * @param int $number Number * @return string */ - public function npgettext($msgctxt, $msgId, $msgIdPlural, $number): string + public function npgettext(string $msgctxt, string $msgId, string $msgIdPlural, int $number): string { - return self::idOrFind($msgId); + if ($number > 1) { + return self::idOrFind($msgIdPlural); + } else { + return self::idOrFind($msgId); + } } /** @@ -347,12 +351,12 @@ public function ngettext(string $msgId, string $msgIdPlural, int $number): strin /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id + * @param string $domain Domain + * @param string $msgctxt msgctxt + * @param string $msgId Message id * @return string */ - public function dpgettext($domain, $msgctxt, $msgId): string + public function dpgettext(string $domain, string $msgctxt, string $msgId): string { return self::idOrFind($msgId); } @@ -360,11 +364,11 @@ public function dpgettext($domain, $msgctxt, $msgId): string /** * Get translation * - * @param mixed $domain Domain - * @param mixed $msgId Message id + * @param string $domain Domain + * @param string $msgId Message id * @return string */ - public function dgettext($domain, $msgId): string + public function dgettext(string $domain, string $msgId): string { return self::idOrFind($msgId); } @@ -372,11 +376,11 @@ public function dgettext($domain, $msgId): string /** * Get translation * - * @param mixed $msgctxt msgctxt - * @param mixed $msgId Message id + * @param string $msgctxt msgctxt + * @param string $msgId Message id * @return string */ - public function pgettext($msgctxt, $msgId): string + public function pgettext(string $msgctxt, string $msgId): string { return self::idOrFind($msgId); }