These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Yii2 module for language switching |
||
4 | * |
||
5 | * @link https://github.com/hiqdev/yii2-language |
||
6 | * @package yii2-language |
||
7 | * @license BSD-3-Clause |
||
8 | * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/) |
||
9 | */ |
||
10 | |||
11 | namespace hiqdev\yii2\language\widgets; |
||
12 | |||
13 | use codemix\localeurls\UrlManager; |
||
14 | use Yii; |
||
15 | |||
16 | /** |
||
17 | * Language Menu widget. |
||
18 | * |
||
19 | * @property Module $module The module to be used, can be found by default. |
||
20 | */ |
||
21 | class LanguageMenu extends \yii\base\Widget |
||
22 | { |
||
23 | use \hiqdev\yii2\language\GetModuleTrait; |
||
24 | |||
25 | public function getLanguages() |
||
26 | { |
||
27 | return $this->getModule()->languages; |
||
0 ignored issues
–
show
|
|||
28 | } |
||
29 | |||
30 | public function getLanguage() |
||
31 | { |
||
32 | return Yii::$app->language; |
||
33 | } |
||
34 | |||
35 | public $view = 'LanguageMenu'; |
||
36 | |||
37 | public function run() |
||
38 | { |
||
39 | return $this->render($this->view, [ |
||
40 | 'language' => $this->getLanguage(), |
||
41 | 'languages' => $this->getLanguages(), |
||
42 | 'selectUrl' => $this->getSelectUrl(), |
||
43 | ]); |
||
44 | } |
||
45 | |||
46 | View Code Duplication | public function getSelectUrl() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
47 | { |
||
48 | if (Yii::$app->urlManager instanceof UrlManager) { |
||
0 ignored issues
–
show
The class
codemix\localeurls\UrlManager does not exist. Did you forget a USE statement, or did you not list all dependencies?
This error could be the result of: 1. Missing dependenciesPHP Analyzer uses your Are you sure this class is defined by one of your dependencies, or did you maybe
not list a dependency in either the 2. Missing use statementPHP does not complain about undefined classes in if ($x instanceof DoesNotExist) {
// Do something.
}
If you have not tested against this specific condition, such errors might go unnoticed.
Loading history...
|
|||
49 | $route = Yii::$app->controller->route; |
||
50 | $params = Yii::$app->request->get(); |
||
51 | array_unshift($params, '/' . $route); |
||
52 | |||
53 | return $params; |
||
54 | } |
||
55 | |||
56 | return ['/' . $this->getModule()->id . '/language/select']; |
||
57 | } |
||
58 | } |
||
59 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.