Restore object state from array

@param  array $spec
@return void
335157
protected function _restoreFromArray(array $spec)
    {
        foreach ($spec as $key => $value) {
            if (property_exists($this, $key)) {
                $this->{$key} = $value;
            }
        }
    }
805328
public function loadState(array $params)
    {
        //loads state from session
        $session = $this->getRememberSession();
        if ($session && $this->getPresenter()->isSignalReceiver($this)) {
            $session->remove();
        } elseif ($session && empty($params) && $session->params) {
            $params = (array) $session->params;
        }

        parent::loadState($params);
    }
1022280
public function group($spec)
    {
        if (!is_array($spec)) {
            $spec = array($spec);
        }

        foreach ($spec as $val) {
            if (preg_match('/\(.*\)/', (string) $val)) {
                $val = new Zend_Db_Expr($val);
            }
            $this->_parts[self::GROUP][] = $val;
        }

        return $this;
    }
606741
public function reset($state = null)
    {
        if (empty($state)) {
            static $initalState = [];
            if (empty($initalState)) {
                $initalState = get_class_vars(__CLASS__);
            }
            $state = $initalState;
        }

        foreach ($state as $property => $value) {
            $this->{$property} = $value;
        }

        return true;
    }
1342081
protected function _pathEncode($spec)
    {
        if (is_string($spec)) {
            $spec = explode('/', $spec);
        }

        $keys = array_keys($this->_encode_path);
        $vals = array_values($this->_encode_path);

        $out = array();
        foreach ((array) $spec as $elem) {
            $out[] = str_replace($keys, $vals, $elem);
        }

        return implode('/', $out);
    }
1146079
public function reset()
    {
        $this->page        = 1;
        $this->perPage     = null;
        $this->parsers     = [];
        $this->sorts       = [];
        $this->searchQuery = null;
        $this->rules       = [
            'page'     => 'numeric',
            'per_page' => 'numeric',
            'sort'     => 'string',
            'q'        => 'string',
        ];
    }
46186
protected function formatSatisfies(array $specs)
    {
        $clauses = array_map(function ($clause) use ($specs) {
            if ($result = $this->formatClause($specs, $clause)) {
                return vsprintf('%s: %s', [
                    ucfirst(str_replace('_', ' ', $clause)),
                    $result,
                ]);
            }
        }, ['from', 'excluded_from', 'on', 'excluded_on', 'to', 'excluded_to']);

        return implode(PHP_EOL, array_filter($clauses));
    }
351126
public function restore(array $settings = array())
    {
        $settings = array_values($settings);

        $reflection = new ReflectionMethod(get_class($this), '__construct');
        $alreadySet = $reflection->getNumberOfParameters();

        $index = 0;

        foreach($this->settings as &$setting)
        {
            if($alreadySet > $index)
            {
                continue;
            }

            if(array_key_exists($index, $settings))
            {
                $setting = $settings[$index] === '' ? NULL : $settings[$index];
            }

            $index++;
        }
    }
262948
private function findFieldsInTableSpec($fieldName, $spec)
    {
        $fields = [];
        if(is_array($spec) && !empty($spec))
        {
            if(array_key_exists($fieldName, $spec))
            {
                $fields = $spec[$fieldName];
            }

            if(isset($spec['joins']))
            {
                foreach($spec['joins'] as $join)
                {
                    $fields = array_merge($fields, $this->findFieldsInTableSpec($fieldName, $join));
                }
            }
        }
        return $fields;
    }
340381
protected function reset()
    {
        $this->params                = array();
        $this->isShared              = true;
        $this->isCloneable           = true;
        $this->reflectionClass       = null;
        $this->reflectionConstructor = null;
        $this->constructorParams     = array();
        $this->parent                = null;
        $this->interfaces            = null;
    }
343516
protected function createInstanceCallback($name, $spec)
    {
        if (is_string($spec) && class_exists($spec)) {
            $spec = new $spec();
        }

        $callback = function () use ($name, $spec) {
            if ($spec instanceof \Closure) {
                return $spec($this);
            } elseif ($spec instanceof ServiceFactory) {
                return $spec->createService($this);
            } elseif (is_object($spec)) {
                return $spec;
            } elseif (is_array($spec)) {
                return $this->createFromArray($name, $spec);
            } elseif (is_null($spec)) {
                throw new Exception\NullServiceException($name);
            }

            throw new Exception\InvalidServiceException($name);
        };

        return $callback;
    }
121373
protected function _setSpec($spec)
    {
        if (!is_null($spec)) {
            $spec = $this->_normalizeIterable($spec);
        }

        $this->spec = $spec;
    }
97940
public function beforeSpec(Spec $spec)
    {
        parent::beforeSpec($spec);

        if ($this->lineLength == self::$maxPerLine) {
            $this->console->writeLn('');
            $this->lineLength = 0;
        }
    }
1309905
public function setSpecification($specification = null)
    {
        $this->checkSpecificationIsArray($specification);

        $this->initProperties($specification);
        $this->initPatternProperties($specification);
        $this->initAdditionalProperties($specification);
    }
423317
private function initPatternProperties(array $specification)
    {
        if (isset($specification[self::PATTERN_PROPERTIES_INDEX])) {
            $this->setPatternProperties($specification[self::PATTERN_PROPERTIES_INDEX]);
        }
    }
626674
public static function reset()
    {
        if (empty(self::$initialState)) {
            self::$initialState = get_class_vars(Inflector::class);
            return;
        }
        foreach (self::$initialState as $key => $val) {
            if ($key != 'initialState') {
                self::${$key} = $val;
            }
        }
        self::$cache = [];
    }
605210
final public function reset(array $modified = array())
    {
        $context = $this->getContext();
        $context->modified = $modified;

        if ($this->invokeCommand('before.reset', $context) !== false)
        {
            $this->_actionReset($context);
            $this->invokeCommand('after.reset', $context);
        }

        $this->_count = KObjectConfig::unbox($context->count);

        return $this;
    }