function merge($hash) { if ($hash instanceof Enumerable) { $hash = $hash->array; } return call_class_method($this->class, 'new_instance', array(array_merge($this->array, $hash))); }
function instance($values) { $instance = call_class_method($this->class, 'new_instance', array($this->members)); $values = func_get_args(); foreach ($this->members as $key => $member) { $instance->{$member} = $values[$key]; } return $instance; }
protected function &__get($property) { if (isset($this->{$property})) { return $this->instance_variables[$property]; } else { $this->instance_variables = array_merge(call_class_method($this->class, 'properties'), $this->instance_variables); if (isset($this->instance_variables[$property])) { return $this->instance_variables[$property]; } else { trigger_error('Undefined property $' . $property, E_USER_ERROR); } } }
function delegate($delegated_methods) { $delegated_methods = func_get_args(); $receiver = array_pop($delegated_methods); if (empty($delegated_methods)) { trigger_error('The last argument to delegate() must be an object or a string representing a class or method', E_USER_ERROR); } else { $class = get_called_class(); $methods =& call_class_method($class, 'methods'); foreach ($delegated_methods as $delegated_method) { if (!isset($methods[$delegated_method])) { $methods[$delegated_method] = array(); } array_unshift($methods[$delegated_method], array($receiver, $delegated_method)); } } }
static function update_derived_modules() { $class = get_called_class(); $ancestors = call_class_method($class, 'ancestors'); foreach (Module::$mixins as $module => &$mixins) { if ($module != $class && in_array($class, $mixins['ancestors'])) { array_splice($mixins['ancestors'], array_search($class, $mixins['ancestors']), count($mixins['ancestors']), $ancestors); $mixins['methods'] = false; $mixins['properties'] = false; } } }
function sort_by($block, $sort_flags = null) { $sorted = $this->inject(new Hash(), '$object[$key] = evaluate_block(\'' . $block . '\', get_defined_vars()); return $object;')->sort($sort_flags); $result = call_class_method($this->class, 'new_instance'); foreach ($sorted as $key => $value) { $result[$key] = $this[$key]; } return $result; }