These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * Yii2 module for language switching |
||
5 | * |
||
6 | * @link https://github.com/hiqdev/yii2-language |
||
7 | * @package yii2-language |
||
8 | * @license BSD-3-Clause |
||
9 | * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/) |
||
10 | */ |
||
11 | |||
12 | namespace hiqdev\yii2\language\widgets; |
||
13 | |||
14 | use codemix\localeurls\UrlManager; |
||
15 | use Yii; |
||
16 | |||
17 | /** |
||
18 | * Language Menu widget. |
||
19 | * |
||
20 | * @property Module $module The module to be used, can be found by default. |
||
21 | */ |
||
22 | class LanguageMenu extends \yii\base\Widget |
||
23 | { |
||
24 | use \hiqdev\yii2\language\GetModuleTrait; |
||
25 | |||
26 | public function getLanguages() |
||
27 | { |
||
28 | return $this->getModule()->languages; |
||
29 | } |
||
30 | |||
31 | public function getLanguage() |
||
32 | { |
||
33 | return Yii::$app->language; |
||
34 | } |
||
35 | |||
36 | public function run() |
||
37 | { |
||
38 | return $this->render('LanguageMenu', [ |
||
39 | 'language' => $this->getLanguage(), |
||
40 | 'languages' => $this->getLanguages(), |
||
41 | 'selectUrl' => $this->getSelectUrl(), |
||
42 | ]); |
||
43 | } |
||
44 | |||
45 | public function getSelectUrl() |
||
46 | { |
||
47 | if (Yii::$app->urlManager instanceof UrlManager) { |
||
0 ignored issues
–
show
|
|||
48 | $route = Yii::$app->controller->route; |
||
49 | $params = Yii::$app->request->get(); |
||
50 | array_unshift($params, '/' . $route); |
||
51 | |||
52 | return $params; |
||
53 | } |
||
54 | |||
55 | return ['/' . $this->getModule()->id . '/language/select']; |
||
56 | } |
||
57 | } |
||
58 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.