Если есть код в AR
/**
* @return ActiveQuery
*/
public function getLabel()
{
// какой-то код
}
То получить ActiveQuery можно только так
$AR->getLabel()
если обратиться через
$AR->label
, то ActiveQuery уже не будет, т.к. метод __get BaseActiveRecord.php его
не пропустит
Типа так делать нельзя?
UPD. Нашел упоминание в
документации.
Note: While this concept looks similar to the object property feature, there is an important difference. For normal object properties the property value is of the same type as the defining getter method. A relation method however returns an yii\db\ActiveQuery instance, while accessing a relation property will either return a yii\db\ActiveRecord instance or an array of these.
Как следствие, такое поведение имеет отношение к любым методам, даже если внутри используются не связи.