Issues (27)

backend/models/search/UserSearch.php (1 issue)

1
<?php
2
namespace backend\models\search;
3
4
use backend\models\User;
5
use yii\data\ActiveDataProvider;
6
7
class UserSearch extends User
8
{
9
    public function rules()
10
    {
11
        return [
12
            [['username'], 'string'],
13
        ];
14
    }
15
16
    /**
17
     * @param array $params
18
     * @return ActiveDataProvider
19
     */
20
    public function search($params = [])
21
    {
22
        $query = User::find();
23
        $dataProvider = new ActiveDataProvider([
24
            'query' => $query,
25
        ]);
26
        $dataProvider->sort = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array('defaultOrder' => ...odels\search\SORT_ASC)) of type array<string,array<string,integer>> is incompatible with the declared type boolean|yii\data\Sort of property $sort.

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..

Loading history...
27
            'defaultOrder' => [
28
                'username' => SORT_ASC,
29
            ],
30
        ];
31
        if (!$this->load($params) || !$this->validate()) {
32
            return $dataProvider;
33
        }
34
        $query->andWhere(['like', 'username', $this->username]);
35
        return $dataProvider;
36
    }
37
}
38