Can someone explain the reason that the get methods (e.g. in viewmodel, view and Orm models) return by reference? - e.g. function & __get($key) {}
It's a little bit of a pain to work with methods which do this as you cannot return the result of an expression but rather have to assign it to a variable and return that. For this reason, I am wondering if the drawbacks outweigh the benefits.
Pretty simple reason, otherwise you couldn't do this:
$view->array['key'] = 'something';
As the array is returned by reference you can deal with it just like an actual object property. So yes the benefits far outweight the drawback you described.