| Conditions | 4 |
| Paths | 3 |
| Total Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 16 | public function search($params) |
||
| 17 | { |
||
| 18 | /* @var $query \yii\db\ActiveQuery */ |
||
| 19 | $query = self::find(); |
||
| 20 | |||
| 21 | $dataProvider = new ActiveDataProvider( |
||
| 22 | [ |
||
| 23 | 'query' => $query, |
||
| 24 | ] |
||
| 25 | ); |
||
| 26 | |||
| 27 | /* @var \yii\db\ActiveRecord|SearchModelTrait $this */ |
||
| 28 | if (!($this->load($params) && $this->validate())) { |
||
| 29 | return $dataProvider; |
||
| 30 | } |
||
| 31 | |||
| 32 | foreach ($this->scenarios()['search'] as $field) { |
||
| 33 | $this->addCondition($query, $this->tableName(), $field); |
||
| 34 | } |
||
| 35 | |||
| 36 | return $dataProvider; |
||
| 37 | } |
||
| 38 | |||
| 49 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.