Conditions | 5 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
14 | 7 | public function actionIndex() |
|
15 | { |
||
16 | 7 | $model = new SettingsForm(); |
|
17 | |||
18 | 7 | if (Yii::$app->request->isPost) { |
|
19 | 5 | if ($model->load(Yii::$app->request->post()) && $model->validate()) { |
|
20 | 3 | Yii::$app->settings->load($model->getAttributes()); |
|
21 | 3 | Yii::$app->session->setFlash('success', Yii::t('app.messages', 'Saved successfully')); |
|
22 | 3 | return $this->refresh(); |
|
23 | } |
||
24 | 2 | if (Yii::$app->request->isAjax) { |
|
25 | 1 | return $this->asJson($this->collectErrors($model)); |
|
|
|||
26 | } |
||
27 | } |
||
28 | |||
29 | 7 | $model->setAttributes(Yii::$app->settings->all()); |
|
30 | |||
31 | 7 | return $this->render('index', ['model' => $model]); |
|
32 | } |
||
33 | } |
||
34 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: