1 | <?php |
||
21 | class IndexAction extends Action |
||
22 | { |
||
23 | /** |
||
24 | * @var callable a PHP callable that will be called to prepare a data provider that |
||
25 | * should return a collection of the models. If not set, [[prepareDataProvider()]] will be used instead. |
||
26 | * The signature of the callable should be: |
||
27 | * |
||
28 | * ```php |
||
29 | * function (IndexAction $action) { |
||
30 | * // $action is the action object currently running |
||
31 | * } |
||
32 | * ``` |
||
33 | * |
||
34 | * The callable should return an instance of [[ActiveDataProvider]]. |
||
35 | * |
||
36 | * If [[dataFilter]] is set the result of [[DataFilter::build()]] will be passed to the callable as a second parameter. |
||
37 | * In this case the signature of the callable should be the following: |
||
38 | * |
||
39 | * ```php |
||
40 | * function (IndexAction $action, mixed $filter) { |
||
41 | * // $action is the action object currently running |
||
42 | * // $filter the built filter condition |
||
43 | * } |
||
44 | * ``` |
||
45 | */ |
||
46 | public $prepareDataProvider; |
||
47 | /** |
||
48 | * @var DataFilter|null data filter to be used for the search filter composition. |
||
49 | * You must setup this field explicitly in order to enable filter processing. |
||
50 | * For example: |
||
51 | * |
||
52 | * ```php |
||
53 | * [ |
||
54 | * 'class' => 'yii\rest\ActiveDataFilter', |
||
55 | * 'searchModel' => function () { |
||
56 | * return (new \yii\base\DynamicModel(['id' => null, 'name' => null, 'price' => null])) |
||
57 | * ->addRule('id', 'integer') |
||
58 | * ->addRule('name', 'trim') |
||
59 | * ->addRule('name', 'string') |
||
60 | * ->addRule('price', 'number'); |
||
61 | * }, |
||
62 | * ] |
||
63 | * ``` |
||
64 | * |
||
65 | * @see DataFilter |
||
66 | * |
||
67 | * @since 2.0.13 |
||
68 | */ |
||
69 | public $dataFilter; |
||
70 | |||
71 | |||
72 | /** |
||
73 | * @return ActiveDataProvider |
||
74 | */ |
||
75 | public function run() |
||
83 | |||
84 | /** |
||
85 | * Prepares the data provider that should return the requested collection of the models. |
||
86 | * @return ActiveDataProvider |
||
87 | */ |
||
88 | protected function prepareDataProvider() |
||
129 | } |
||
130 |
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: