_properties = $properties; } /** * Create an instance with a list of arguments passed to the constructor. * @param mixed $param1 * @param mixed $param2... * @return object */ public function newInstance() { return $this->newInstanceArgs(func_get_args()); } /** * Create an instance with the given array of arguments in the constructor. * @param mixed[] $args * @return object */ public function newInstanceArgs($args) { if ($this->getConstructor()) { $o = parent::newInstanceArgs($args); } else { $o = parent::newInstance(); } foreach ($this->_properties as $k => $v) { $setter = 'set' . ucfirst($k); $this->getMethod($setter)->invoke($o, $v); } return $o; } }