GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Issues (910)

framework/rest/UpdateAction.php (2 issues)

Labels
1
<?php
2
/**
3
 * @link https://www.yiiframework.com/
4
 * @copyright Copyright (c) 2008 Yii Software LLC
5
 * @license https://www.yiiframework.com/license/
6
 */
7
8
namespace yii\rest;
9
10
use Yii;
11
use yii\base\Model;
12
use yii\db\ActiveRecord;
13
use yii\web\ServerErrorHttpException;
14
15
/**
16
 * UpdateAction implements the API endpoint for updating a model.
17
 *
18
 * For more details and usage information on UpdateAction, see the [guide article on rest controllers](guide:rest-controllers).
19
 *
20
 * @author Qiang Xue <[email protected]>
21
 * @since 2.0
22
 */
23
class UpdateAction extends Action
24
{
25
    /**
26
     * @var string the scenario to be assigned to the model before it is validated and updated.
27
     */
28
    public $scenario = Model::SCENARIO_DEFAULT;
29
30
31
    /**
32
     * Updates an existing model.
33
     * @param string $id the primary key of the model.
34
     * @return \yii\db\ActiveRecordInterface the model being updated
35
     * @throws ServerErrorHttpException if there is any error when updating the model
36
     */
37
    public function run($id)
38
    {
39
        /* @var $model ActiveRecord */
40
        $model = $this->findModel($id);
41
42
        if ($this->checkAccess) {
43
            call_user_func($this->checkAccess, $this->id, $model);
44
        }
45
46
        $model->scenario = $this->scenario;
47
        $model->load(Yii::$app->getRequest()->getBodyParams(), '');
0 ignored issues
show
The method getBodyParams() does not exist on yii\console\Request. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
        $model->load(Yii::$app->getRequest()->/** @scrutinizer ignore-call */ getBodyParams(), '');
Loading history...
It seems like Yii::app->getRequest()->getBodyParams() can also be of type object; however, parameter $data of yii\base\Model::load() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
        $model->load(/** @scrutinizer ignore-type */ Yii::$app->getRequest()->getBodyParams(), '');
Loading history...
48
        if ($model->save() === false && !$model->hasErrors()) {
49
            throw new ServerErrorHttpException('Failed to update the object for unknown reason.');
50
        }
51
52
        return $model;
53
    }
54
}
55