I'm a PHP developer, and what do PHP developers do? They create frameworks, so I'm having my way with my little mvc framework project and I've stumbled across a design problem I'd like some opinions on.For my models I've chosen to take the data objects path (if that's the correct terminology), not a big fan of active record. Essentially there is a gateway pattern that handles persistence and the model is just there to hold data.Problem is, how do I get this data into the model.Warning: this involves PHP internals and my performance obsessionThis is what I initially had.abstract class Model {    public function __construct(array $data = []) {        foreach($data as $key => $value) $this->$key = $value;    }    }After writing that code my performance related disorder started kicking in and I thought  that this iteration is completely unnecessary and I could replace it with an assignment.abstract class Model {    public $props;    public function __construct(array $data = []) {        $this->props = $data;    }    }Running benchmarks on both cases justified my reasoning as the first one turned out to be up to 20 times slower (depending on $data size), so naturally I decided I'm going to stick with the single assignment.It wasn't long before this introduced a new problem - how the hell am I going to access the properties. I can't go calling $model->props['property'] for a bunch of reasons - first it's ugly, second I can't get code completion on that and further more the code is open to errors like someone (a dumber me in future) calling $model->props = 'not so smart assignment' and then I'll start getting errors all over the place. So I figured I must protect this property and give proper access to it, like with getters and setters:abstract class Model {    protected $props;    public function __construct(array $data = []) {        $this->props = $data;    }    public function __get($name) { ... }    public function __set($name, $value) { ... }}But it doesn't take a genius (obviously, me) to realize that calling those functions directly will be times faster than having PHP figure out what I'm trying to do and call them for me, so I dropped the magic part and left just get() and set() methods. Now I solved the problem regarding the access to props but I didn't solve the problem regarding code completion and boy that would be a pain to refactor, if I ever have to, in future. Additionally I decided to benchmark what would be the difference between accessing an object's property directly as opposed to getting it from props with get(), results: calling function is 6 times slower than accessing directly.Basically how I see the decision I have to take now is I have to chose between slow model data assignment vs slow model data retrieval.Is there anything I'm missing, I'm open to any kind of suggestions.
Designing a model
object oriented;php;mvc