In models you have those methods that will be used for properties.
Simple Example:
/**
* @property SubItem $subItems
*/
class Item extends ActiveRecord {
/**
* @return ActiveQuery
*/
public function getSubItems() {
return $this->hasMany(SubItem::className(), ['id' => 'parent_item_id']);
}
}
Do you think it is okay to parameterize such a method?
For Example:
/**
* @property SubItem $subItems
*/
class Item extends ActiveRecord {
/**
* @return ActiveQuery
*/
public function getSubItems($name = null) {
return $this->hasMany(SubItem::className(), ['id' => 'parent_item_id'])->filterWhere(['name' => $name]);
}
}
The property would still work but the method could be used with parameters too.
What would you say? Would you discourage from this? Are there any problems with this?
Alternatively I could create a method getSubItemsWithName($name) that has no property.