Issues (2884)

src/App/I18n/Translator.php (9 issues)

1
<?php
2
0 ignored issues
show
Missing file doc comment
Loading history...
3
namespace Jaxon\App\I18n;
4
5
/**
0 ignored issues
show
Block comments must be started with /*
Loading history...
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
Missing doc comment for class Translator
Loading history...
22
{
23
    /**
0 ignored issues
show
Parameter $xConfig should have a doc-comment as per coding-style.
Loading history...
Parameter $sName should have a doc-comment as per coding-style.
Loading history...
24
     * @inheritDoc
25
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
26
    public function onChange(Config $xConfig, string $sName)
0 ignored issues
show
Expected 2 blank lines before function; 0 found
Loading history...
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 ignore-type  annotation

31
            $this->setLocale(/** @scrutinizer ignore-type */ $xConfig->getOption('core.language'));
Loading history...
32
        }
33
    }
0 ignored issues
show
Expected 2 blank lines after function; 0 found
Loading history...
34
}
35