| Conditions | 5 |
| Paths | 3 |
| Total Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function run() |
||
| 20 | { |
||
| 21 | $model = new $this->modelClass; |
||
| 22 | |||
| 23 | if (($ids = Yii::$app->request->post('selection')) !== null) { |
||
| 24 | $models = $model::findAll($ids); |
||
| 25 | $operation = Yii::$app->request->post('operation'); |
||
| 26 | |||
| 27 | if (isset($this->actions[$operation])) { |
||
| 28 | $attrubutes = $this->actions[$operation]; |
||
| 29 | foreach ($models as $model) { |
||
| 30 | switch ($operation) { |
||
| 31 | case 'delete': |
||
| 32 | $model->delete(); |
||
| 33 | break; |
||
| 34 | default: |
||
| 35 | $model->setAttributes($attrubutes, false); |
||
| 36 | $model->save(false); |
||
| 37 | break; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | } |
||
| 41 | } |
||
| 42 | |||
| 43 | return $this->controller->asJson(true); |
||
|
|
|||
| 44 | } |
||
| 45 | } |
||
| 46 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: