These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace hauntd\vote\widgets; |
||
4 | |||
5 | use hauntd\vote\assets\VoteAsset; |
||
6 | use hauntd\vote\models\VoteAggregate; |
||
7 | use hauntd\vote\traits\ModuleTrait; |
||
8 | use yii\base\InvalidParamException; |
||
9 | use yii\base\Widget; |
||
10 | use Yii; |
||
11 | |||
12 | /** |
||
13 | * @author Alexander Kononenko <[email protected]> |
||
14 | * @package hauntd\vote\widgets |
||
15 | */ |
||
16 | abstract class BaseWidget extends Widget |
||
17 | { |
||
18 | use ModuleTrait; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | public $entity; |
||
24 | |||
25 | /** |
||
26 | * @var null|\yii\db\ActiveRecord |
||
27 | */ |
||
28 | public $model; |
||
29 | |||
30 | /** |
||
31 | * @var null|integer; |
||
32 | */ |
||
33 | public $targetId; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | public $voteUrl; |
||
39 | |||
40 | /** |
||
41 | * @var null|\hauntd\vote\models\VoteAggregate |
||
42 | */ |
||
43 | public $aggregateModel; |
||
44 | |||
45 | /** |
||
46 | * @var null|integer |
||
47 | */ |
||
48 | public $userValue = null; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | public $jsBeforeVote; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | public $jsAfterVote; |
||
59 | |||
60 | /** |
||
61 | * @var string |
||
62 | */ |
||
63 | public $jsCodeKey = 'vote'; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | */ |
||
68 | public $jsErrorVote; |
||
69 | |||
70 | /** |
||
71 | * @var string |
||
72 | */ |
||
73 | public $jsShowMessage; |
||
74 | |||
75 | /** |
||
76 | * @var string |
||
77 | */ |
||
78 | public $jsChangeCounters; |
||
79 | |||
80 | /** |
||
81 | * @var array |
||
82 | */ |
||
83 | public $options = []; |
||
84 | |||
85 | /** |
||
86 | * @var string |
||
87 | */ |
||
88 | public $viewFile = 'vote'; |
||
89 | |||
90 | /** |
||
91 | * @param $classes |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getSelector($classes) |
||
95 | { |
||
96 | $classes = str_replace(' ', '.', $classes); |
||
97 | return ".{$classes}[data-entity=\"' + entity + '\"][data-target-id=\"' + target + '\"]"; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * @inheritdoc |
||
102 | * @throws \yii\base\InvalidConfigException |
||
103 | */ |
||
104 | public function init() |
||
105 | { |
||
106 | parent::init(); |
||
107 | |||
108 | if (!isset($this->entity) || !isset($this->model)) { |
||
109 | throw new InvalidParamException(Yii::t('vote', 'Entity and model must be set.')); |
||
110 | } |
||
111 | |||
112 | $this->initDefaults(); |
||
113 | |||
114 | if ($this->getModule()->registerAsset) { |
||
115 | $this->view->registerAssetBundle(VoteAsset::class); |
||
116 | } |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * Initialize widget with default options. |
||
121 | * |
||
122 | * @throws \yii\base\InvalidConfigException |
||
123 | */ |
||
124 | public function initDefaults() |
||
125 | { |
||
126 | if (!isset($this->voteUrl)) { |
||
127 | $this->voteUrl = Yii::$app->getUrlManager()->createUrl(['vote/default/vote']); |
||
128 | } |
||
129 | if (!isset($this->targetId)) { |
||
130 | $this->targetId = $this->model->getPrimaryKey(); |
||
131 | } |
||
132 | if (!isset($this->aggregateModel)) { |
||
133 | $this->aggregateModel = VoteAggregate::findOne([ |
||
1 ignored issue
–
show
|
|||
134 | 'entity' => $this->getModule()->encodeEntity($this->entity), |
||
135 | 'target_id' => $this->targetId, |
||
136 | ]); |
||
137 | } |
||
138 | } |
||
139 | } |
||
140 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..