1 | <?php |
||||
2 | |||||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
3 | namespace Jaxon\App\I18n; |
||||
4 | |||||
5 | /** |
||||
0 ignored issues
–
show
|
|||||
6 | * Translator.php |
||||
7 | * |
||||
8 | * A translator coupled with a config event listener. |
||||
9 | * |
||||
10 | * @package jaxon-core |
||||
11 | * @author Thierry Feuzeu <[email protected]> |
||||
12 | * @copyright 2022 Thierry Feuzeu <[email protected]> |
||||
13 | * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
||||
14 | * @link https://github.com/jaxon-php/jaxon-core |
||||
15 | */ |
||||
16 | |||||
17 | use Jaxon\App\Config\ConfigListenerInterface; |
||||
18 | use Jaxon\Utils\Config\Config; |
||||
19 | use Jaxon\Utils\Translation\Translator as BaseTranslator; |
||||
20 | |||||
21 | class Translator extends BaseTranslator implements ConfigListenerInterface |
||||
0 ignored issues
–
show
|
|||||
22 | { |
||||
23 | /** |
||||
0 ignored issues
–
show
|
|||||
24 | * @inheritDoc |
||||
25 | */ |
||||
0 ignored issues
–
show
|
|||||
26 | public function onChange(Config $xConfig, string $sName) |
||||
0 ignored issues
–
show
|
|||||
27 | { |
||||
28 | // Set the library language any time the config is changed. |
||||
29 | if($sName === '' || $sName === 'core.language') |
||||
30 | { |
||||
31 | $this->setLocale($xConfig->getOption('core.language')); |
||||
0 ignored issues
–
show
It seems like
$xConfig->getOption('core.language') can also be of type null ; however, parameter $sLocale of Jaxon\Utils\Translation\Translator::setLocale() does only seem to accept string , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
32 | } |
||||
33 | } |
||||
0 ignored issues
–
show
|
|||||
34 | } |
||||
35 |