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:
parent
d423a0bda7
commit
0ea1334dce
3 changed files with 21 additions and 5 deletions
|
|
@ -29,9 +29,5 @@ parameters:
|
||||||
message: '#of function str_replace expects#'
|
message: '#of function str_replace expects#'
|
||||||
paths:
|
paths:
|
||||||
- src/GlossTranslator.php
|
- src/GlossTranslator.php
|
||||||
-
|
|
||||||
message: '#should return Lean\\Gloss\\GlossTranslator\|string\|void\|null but returns array\|string#'
|
|
||||||
paths:
|
|
||||||
- src/helpers.php
|
|
||||||
|
|
||||||
checkMissingIterableValueType: false
|
checkMissingIterableValueType: false
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ use Illuminate\Support\Facades\Facade;
|
||||||
* @method static ?string get($key, $replace = [], $locale = null) Get a translation string.
|
* @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 ?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.
|
* @method static void extend(string $shortKey, callable(string, callable): string $value) Extend a translation string.
|
||||||
|
*
|
||||||
|
* @see \Lean\Gloss\GlossTranslator
|
||||||
*/
|
*/
|
||||||
class Gloss extends Facade
|
class Gloss extends Facade
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,15 @@ class GlossTranslator extends Translator
|
||||||
$this->extensions[$shortKey][] = $value;
|
$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)
|
public function get($key, array $replace = [], $locale = null, $fallback = true)
|
||||||
{
|
{
|
||||||
if (array_key_exists($key, $this->extensions)) {
|
if (array_key_exists($key, $this->extensions)) {
|
||||||
|
|
@ -118,7 +127,16 @@ class GlossTranslator extends Translator
|
||||||
return $this->getWithoutExtensions($key, $replace, $locale, $fallback);
|
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)
|
return $this->getKeyOverride($key, $replace)
|
||||||
?? $this->getValueOverride($key, $replace)
|
?? $this->getValueOverride($key, $replace)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue