1
0
Fork 0
mirror of https://github.com/archtechx/gloss.git synced 2025-12-12 11:14:04 +00:00

Fix static analysis issue with string|array

This commit is contained in:
Samuel Štancl 2020-12-13 21:04:00 +01:00
parent d423a0bda7
commit 0ea1334dce
3 changed files with 21 additions and 5 deletions

View file

@ -15,6 +15,8 @@ use Illuminate\Support\Facades\Facade;
* @method static ?string get($key, $replace = [], $locale = null) Get a translation string.
* @method static ?string choice($key, $replace = [], $locale = null) Get a translation according to an integer value.
* @method static void extend(string $shortKey, callable(string, callable): string $value) Extend a translation string.
*
* @see \Lean\Gloss\GlossTranslator
*/
class Gloss extends Facade
{

View file

@ -89,6 +89,15 @@ class GlossTranslator extends Translator
$this->extensions[$shortKey][] = $value;
}
/**
* Get a translation string.
*
* @param string $key
* @param array $replace
* @param string|null $locale
* @param bool $fallback
* @return string
*/
public function get($key, array $replace = [], $locale = null, $fallback = true)
{
if (array_key_exists($key, $this->extensions)) {
@ -118,7 +127,16 @@ class GlossTranslator extends Translator
return $this->getWithoutExtensions($key, $replace, $locale, $fallback);
}
protected function getWithoutExtensions($key, $replace = [], $locale = null, $fallback = true)
/**
* Get a translation string and skip extensions.
*
* @param string $key
* @param array $replace
* @param string|null $locale
* @param bool $fallback
* @return string
*/
protected function getWithoutExtensions(string $key, $replace = [], $locale = null, $fallback = true)
{
return $this->getKeyOverride($key, $replace)
?? $this->getValueOverride($key, $replace)