Zend的代码。
1.
if ($options instanceof Zend_Config) { $options = $options->toArray(); } public function setOptions(array $options) { $methods = get_class_methods($this); foreach ($options as $key => $value) { $method = 'set' . ucfirst($key); if (in_array($method, $methods)) { $this->$method($value); } } return $this; } public function setNamespace($namespace) { $this->_namespace = rtrim((string) $namespace, '_'); return $this; } public function setBasePath($path) { $this->_basePath = (string) $path; return $this; }