initialize config

create magic method config

@param array
@return array
545104
public function updateConfig(){
	
		foreach($this->_config as $name => $val){
		
			$method = '__Set'._camelize($name);
			
			if(method_exists($this,$method)){
				$this->_config[$name] = call_user_func(array($this,$method),$val);
			}
		}
		return $this;
	}
955847
public function getConfigArray()
    {
        if ($this->_configArray === null) {
            if (!file_exists($this->configFile)) {
                if (!$this->getIsCli()) {
                    throw new Exception("Unable to load the config file '".$this->configFile."'.");
                }
                
                $config = ['id' => 'consoleapp', 'basePath' => dirname(__DIR__)];
            } else {
                $config = require $this->configFile;
            }
    
            if (!is_array($config)) {
                throw new Exception("config file '".$this->configFile."' found but no array returning.");
            }
            
            // preset the values from the defaultConfigArray
            if (!empty($this->prependConfigArray())) {
                $config = ArrayHelper::merge($config, $this->prependConfigArray());
            }
         
            $this->_configArray = $config;
        }

        return $this->_configArray;
    }
535456
public function configure($_array = NULL) {
		if ( $_array != NULL ) {
			if ( isset( $_array['x'] ) ) $this->_config['x'] = $_array['x'];
			if ( isset( $_array['y'] ) ) $this->_config['y'] = $_array['y'];
			if ( isset( $_array['w'] ) ) $this->_config['w'] = $_array['w'];
			if ( isset( $_array['h'] ) ) $this->_config['h'] = $_array['h'];
			if ( isset( $_array['f'] ) ) $this->_config['f'] = $_array['f'];
		}
		return self::$_instance;
	}
730913
function init(config) {
            Object.keys(config).forEach(function (property) {
                this[property] = config[property];
            }, this);
        }
1267140
private function AssignSettingsToArray() {
        try {
            if ($this->app->UnitTestingEnabled) {
                $SettingsClass = "\\Puzzlout\\Framework\\Tests\\AppSettings";
                $this->settings[$this->app->name] = $SettingsClass::Init()->GetSettings();
                return;
            }
            $SettingsClass = "\\Applications\\" . $this->app->name . "\\Config\\AppSettings";
            $this->settings[$this->app->name] = $SettingsClass::Init()->GetSettings();
        } catch (\ErrorException $exc) {
            throw new \RuntimeException("Couldn't execute the method $GetMethod in $SettingsClass", 0, $exc);
        }
    }
364971
public function init( $config = [ ] )
    {
        if ( isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) )
        {
            $this->userAgent = $_SERVER[ 'HTTP_USER_AGENT' ];
        }
        if ( isset( $_SERVER[ 'SERVER_NAME' ] ) )
        {
            $this->server = $_SERVER[ 'SERVER_NAME' ];
        }
        if ( isset( $_SERVER[ 'SERVER_PORT' ] ) )
        {
            $this->port = $_SERVER[ 'SERVER_PORT' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_METHOD' ] ) )
        {
            $this->method = $_SERVER[ 'REQUEST_METHOD' ];
        }
        if ( isset( $_SERVER[ 'QUERY_STRING' ] ) )
        {
            $this->query = $_SERVER[ 'QUERY_STRING' ];
        }
        if ( isset( $_SERVER[ 'SCRIPT_NAME' ] ) )
        {
            $this->script = $_SERVER[ 'SCRIPT_NAME' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_URI' ] ) )
        {
            $this->requestUri = $_SERVER[ 'REQUEST_URI' ];
        }
        if ( isset( $_SERVER[ 'REQUEST_SCHEME' ] ) )
        {
            $this->scheme = $_SERVER[ 'REQUEST_SCHEME' ];
        }

        $request = str_replace( $_SERVER[ 'SCRIPT_NAME' ], '', $this->requestUri );

        $elements = explode( '/', $request );

        if ( '' === $elements[ 0 ] )
        {
            array_shift( $elements );
        }

        if ( 2 <= count( $elements ) )
        {
            $this->route = $elements[ 0 ] . '/' . $elements[ 1 ];

            array_shift( $elements );
            array_shift( $elements );

            if ( 0 < count( $elements ) )
            {
                $this->params = $elements;
            }
        }
        else if ( 1 === count( $elements ) )
        {
            $this->route = $elements[ 0 ];

            array_shift( $elements );
        }
    }
1359200
public static function mergeConfig(): array
    {
        $args = \func_get_args();
        $res = array_shift($args) ?: [];
        foreach ($args as $items) {
            if (!\is_array($items)) {
                continue;
            }
            foreach ($items as $k => $v) {
                if ($v instanceof \yii\helpers\UnsetArrayValue || $v instanceof \Yiisoft\Arrays\UnsetArrayValue) {
                    unset($res[$k]);
                } elseif ($v instanceof \yii\helpers\ReplaceArrayValue || $v instanceof \Yiisoft\Arrays\ReplaceArrayValue) {
                    $res[$k] = $v->value;
                } elseif (\is_int($k)) {
                    /// XXX skip repeated values
                    if (\in_array($v, $res, true))  {
                        continue;
                    }
                    if (isset($res[$k])) {
                        $res[] = $v;
                    } else {
                        $res[$k] = $v;
                    }
                } elseif (\is_array($v) && isset($res[$k]) && \is_array($res[$k])) {
                    $res[$k] = self::mergeConfig($res[$k], $v);
                } else {
                    $res[$k] = $v;
                }
            }
        }

        return $res;
    }
819990
public function init()
    {
        if ($this->initialized) {
            return;
        }

        $parameters = [];

        foreach ($this->parameterRepository->getAllParameters() as $parameter) {
            $configurationName = $parameter->getConfigurationName();

            if (!isset($parameters[$configurationName])) {
                $parameters[$configurationName] = [];
            }

            $parameters[$configurationName][$parameter->getName()] = $parameter;
        }

        $this->persistedParameters = $parameters;

        foreach ($this->configurations as $configuration) {
            $configurationName = $configuration->getName();
            $this->initConfiguration(
                $configuration,
                isset($parameters[$configurationName]) ? $parameters[$configurationName] : []
            );
        }

        $this->initialized = true;
    }
1116228
protected function magicInit()
    {
        if (!$this->magicInited) {
            $this->magicFields = array_replace($this->magicFields, $this->magicGetDefaults());
            $this->magicInited = true;
        }
    }
490333
public function buildAttributes($array)
    {
        $output = array();

        if ($array instanceof KObjectConfig) {
            $array = KObjectConfig::unbox($array);
        }

        if (is_array($array))
        {
            foreach ($array as $key => $item)
            {
                if (is_array($item)) {
                    $item = implode(' ', $item);
                }

                if (is_bool($item))
                {
                    if ($item === false) continue;
                    $item = $key;
                }

                $output[] = $key . '="' . str_replace('"', '&quot;', $item) . '"';
            }
        }

        return implode(' ', $output);
    }
838203
public function create_config()
    {
        $config = array();

        foreach ($this->config as $prop => $default) {
            $is_default = !isset($_POST["_$prop"]);
            $value      = !$is_default || $this->bool_config_props[$prop] ? $_POST["_$prop"] : $default;

            // always disable installer
            if ($prop == 'enable_installer') {
                $value = false;
            }

            // reset useragent to default (keeps version up-to-date)
            if ($prop == 'useragent' && stripos($value, 'Roundcube Webmail/') !== false) {
                $value = $this->defaults[$prop];
            }

            // generate new encryption key, never use the default value
            if ($prop == 'des_key' && $value == $this->defaults[$prop]) {
                $value = rcube_utils::random_bytes(24);
            }

            // convert some form data
            if ($prop == 'debug_level' && !$is_default) {
                if (is_array($value)) {
                    $val = 0;
                    foreach ($value as $dbgval) {
                        $val += intval($dbgval);
                    }
                    $value = $val;
                }
            }
            else if ($prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
                if ($_POST['_dbtype'] == 'sqlite') {
                    $value = sprintf('%s://%s?mode=0646', $_POST['_dbtype'],
                        $_POST['_dbname']{0} == '/' ? '/' . $_POST['_dbname'] : $_POST['_dbname']);
                }
                else if ($_POST['_dbtype']) {
                    $value = sprintf('%s://%s:%s@%s/%s', $_POST['_dbtype'],
                        rawurlencode($_POST['_dbuser']), rawurlencode($_POST['_dbpass']), $_POST['_dbhost'], $_POST['_dbname']);
                }
            }
            else if ($prop == 'smtp_auth_type' && $value == '0') {
                $value = '';
            }
            else if ($prop == 'default_host' && is_array($value)) {
                $value = self::_clean_array($value);
                if (count($value) <= 1) {
                    $value = $value[0];
                }
            }
            else if ($prop == 'mail_pagesize' || $prop == 'addressbook_pagesize') {
                $value = max(2, intval($value));
            }
            else if ($prop == 'smtp_user' && !empty($_POST['_smtp_user_u'])) {
                $value = '%u';
            }
            else if ($prop == 'smtp_pass' && !empty($_POST['_smtp_user_u'])) {
                $value = '%p';
            }
            else if (is_bool($default)) {
                $value = (bool) $value;
            }
            else if (is_numeric($value)) {
                $value = intval($value);
            }
            else if ($prop == 'plugins' && !empty($_POST['submit'])) {
                $value = array();
                foreach (array_keys($_POST) as $key) {
                    if (preg_match('/^_plugins_*/', $key)) {
                        array_push($value, $_POST[$key]);
                    }
                }
            }

            // skip this property
            if ($value == $this->defaults[$prop]
                && (!in_array($prop, $this->local_config)
                    || in_array($prop, array_merge($this->obsolete_config, array_keys($this->replaced_config)))
                    || preg_match('/^db_(table|sequence)_/', $prop)
                )
            ) {
                continue;
            }

            // save change
            $this->config[$prop] = $value;
            $config[$prop]       = $value;
        }

        $out = "<?php\n\n";
        $out .= "/* Local configuration for Roundcube Webmail */\n\n";

        foreach ($config as $prop => $value) {
            // copy option descriptions from existing config or defaults.inc.php
            $out .= $this->comments[$prop];
            $out .= "\$config['$prop'] = " . self::_dump_var($value, $prop) . ";\n\n";
        }

        return $out;
    }
612903
private static function init()
	{
		$classes[] = array('id' => '1', 'name' => 'uppercase', 'regex' => '[A-Z]',                                       'flag' => '1');
		$classes[] = array('id' => '2', 'name' => 'numeric',   'regex' => '[0-9]',                                       'flag' => '1');
		$classes[] = array('id' => '3', 'name' => 'lowercase', 'regex' => '[a-z]',                                       'flag' => '1');
		$classes[] = array('id' => '4', 'name' => 'special',   'regex' => '[!"\'(),-.:;?[`{}#$%&*+<=>@^_|~\]\/\\\]',     'flag' => '1');
		$classes[] = array('id' => '5', 'name' => 'nonalpha',  'regex' => '[!"\'(),\-.:;?[`{}#$%&*+<=>@^_|~\]\/\\\0-9]', 'flag' => '0');
		$classes[] = array('id' => '6', 'name' => 'alpha',     'regex' => '[A-Za-z]',                                    'flag' => '0');

		self::$classes = $classes;
	}
897929
function _Array(conf) {
  var arr = [];
  var arrDb = [];
  var type = '';
  var id = '';
  var classId = '';
  var propertyName = '';
  var isReadOnly = false;
  var isClassName = false;

  conf = conf || {};
  type = conf.type || '';
  id = conf.id || '';
  propertyName = conf.propertyName || '';
  arrDb = conf.arr || [];
  classId = conf.classId || '';

  if (typeof conf.readOnly !== 'undefined') {
    isReadOnly = conf.readOnly;
  }

  isClassName = $metamodel.isClassName(type);

  // init
  arrDb.forEach(function(val) {
    if (isClassName) {
      arr.push($helper.getRuntime().require(val));
    } else {
      arr.push(val);
    }
  });

  /**
   * @method _copy
   * @private
   * @description copy the array
   */
  function _copy() {
    var i = 0;
    var j = 0;
    var length = arr.length;

    arrDb.forEach(function(val) {
      if (isClassName) {
        arr[i] = $helper.getRuntime().require(val);
      } else {
        arr[i] = val;
      }
      i = i + 1;
    });

    for (j = i; j < length; j++) {
      delete arr[j];
    }
    arr.length = arrDb.length;
  }

  /**
   * @method _add
   * @param {String} val value to add
   * @param {String} action type of action
   * @param {Number} start
   * @param {String} deleteCount
   * @private
   * @description add an item in the array
   */
  function _add(val, action, start, deleteCount) {
    var i = 0;
    var length = 0;
    var del = [];

    if (!isReadOnly) {
      if (isClassName) {
        if (val && $metamodel.inheritFrom(val.constructor.name, type)) {
          switch (true) {
            case action === 'push':
              arrDb.push(val.id());
              break;
            case action === 'unshift':
              arrDb.unshift(val.id());
              break;
            case action === 'splice':
              del = arrDb.splice(start, deleteCount, val);

              length = del.length;
              for (i = 0; i < length; i++) {
                $workflow.process({
                  component: id,
                  state: propertyName,
                  data: [store[del[i]], 'remove']
                });
              }
              break;
            default:
              break;
          }

          if ($helper.isRuntime()) {
            $helper
              .getRuntime()
              .require('db')
              .update({
                collection: classId,
                id: id,
                field: propertyName,
                value: arrDb
              });
          }

          $workflow.process({
            component: id,
            state: propertyName,
            data: [val, 'add']
          });
        } else {
          $log.invalidPropertyName(id, classId, propertyName, val, type);
        }
      } else {
        if (val && $metamodel.isValidType(val, type)) {
          switch (true) {
            case action === 'push':
              arrDb.push(val);
              break;
            case action === 'unshift':
              arrDb.unshift(val);
              break;
            case action === 'splice':
              arrDb.splice(start, deleteCount, val);
              break;
            default:
              break;
          }

          if ($helper.isRuntime()) {
            $helper
              .getRuntime()
              .require('db')
              .update({
                collection: classId,
                id: id,
                field: propertyName,
                value: arrDb
              });
          }

          $workflow.process({
            component: id,
            state: propertyName,
            data: [val, 'add']
          });
        } else {
          $log.invalidPropertyName(id, classId, propertyName, val, type);
        }
      }
    } else {
      $log.readOnlyProperty(id, classId, propertyName);
    }
    return arrDb.length;
  }

  /**
   * @method _remove
   * @param {String} action
   * @private
   * @description remove an item from the array
   */
  function _remove(action) {
    var result;
    var val = null;

    if (!isReadOnly) {
      if (arrDb.length !== 0) {
        switch (true) {
          case action === 'pop':
            val = arrDb.pop();
            break;
          case action === 'shift':
            val = arrDb.shift();
            break;
          default:
            break;
        }

        if ($helper.isRuntime()) {
          $helper
            .getRuntime()
            .require('db')
            .update({
              collection: classId,
              id: id,
              field: propertyName,
              value: arrDb
            });
        }

        if (isClassName) {
          result = store[val];
        } else {
          result = val;
        }

        $workflow.process({
          component: id,
          state: propertyName,
          data: [result, 'remove']
        });
      }
    } else {
      $log.readOnlyProperty(id, classId, propertyName);
    }
    return result;
  }

  /**
   * @method push
   * @param {_Component|Object} val
   * @description Override push method
   */
  arr.push = function push(val) {
    var result = _add(val, 'push');

    arr[arr.length] = val;

    return result;
  };

  /**
   * @method pop
   * @returns {_Component|Object} value
   * @description Override pop method
   */
  arr.pop = function pop() {
    var result = _remove('pop');
    var length = arr.length;

    if (length !== 0) {
      delete arr[length];
      arr.length = length - 1;
    }

    return result;
  };

  /**
   * @method shift
   * @returns {_Component|Object} value
   * @description Override shift method
   */
  arr.shift = function shift() {
    var result = _remove('shift');
    _copy();

    return result;
  };

  /**
   * @method unshift
   * @param {_Component|Object} val
   * @description Override unshift method
   */
  arr.unshift = function unshift(val) {
    var result = _add(val, 'unshift');
    _copy();

    return result;
  };

  /**
   * @method push
   * @param {_Component|Object} arr
   * @description Override concat method
   */
  arr.concat = function concat(arr) {
    var i = 0;
    var length = 0;
    var result = null;

    if (Array.isArray(arr)) {
      length = arr.length;
      for (i = 0; i < length; i++) {
        _add(arr[i], 'push');
      }
    }

    conf.arr = arrDb;

    result = new _Array(conf);
    _copy();

    return result;
  };

  /**
   * @method sort
   * @param {Function} funct the sort function
   * @returns {_Array} the current _Array
   * @description Override sort method
   */
  arr.sort = function sort(funct) {
    arrDb.sort(funct);

    if ($helper.isRuntime()) {
      $helper
        .getRuntime()
        .require('db')
        .update({
          collection: classId,
          id: id,
          field: propertyName,
          value: arrDb
        });
    }

    _copy();

    return arr;
  };

  /**
   * @method reverse
   * @returns {_Array} the reversed _Array
   * @description Override reverse method
   */
  arr.reverse = function reverse() {
    arrDb.reverse();

    if ($helper.isRuntime()) {
      $helper
        .getRuntime()
        .require('db')
        .update({
          collection: classId,
          id: id,
          field: propertyName,
          value: arrDb
        });
    }

    _copy();

    return arr;
  };

  /**
   * @method splice
   * @returns {_Array} the spliced _Array
   * @description Override splice method
   */
  arr.splice = function splice(start, deleteCount, val) {
    var result = [];
    var i = 0;
    var length = 0;
    var data = null;

    if (typeof val !== 'undefined') {
      _add(val, 'splice', start, deleteCount);
    } else {
      result = arrDb.splice(start, deleteCount);

      if ($helper.isRuntime()) {
        $helper
          .getRuntime()
          .require('db')
          .update({
            collection: classId,
            id: id,
            field: propertyName,
            value: arrDb
          });
      }

      length = result.length;
      for (i = 0; i < length; i++) {
        if (isClassName) {
          data = store[result[i]];
        } else {
          data = result[i];
        }

        $workflow.process({
          component: id,
          state: propertyName,
          data: [data, 'remove']
        });
      }
    }

    _copy();

    return result;
  };

  /**
   * @method slice
   * @returns {_Array} the sliced _Array
   * @description Override slice method
   */
  arr.slice = function slice(begin, end) {
    var result = arrDb.slice(begin, end);
    _copy();

    return result;
  };

  return arr;
}
1351402
protected function initialiseConfiguration()
    {
        $configuration = $this->registerConfiguration($this->environment);

        if ( ! is_array($configuration)) {
            throw new \RuntimeException(sprintf(
                'The configuration must be a valid array (%s given).',
                $this->varToString($configuration)
            ));
        }

        return $this->configuration = new Configuration($configuration);
    }
991183
protected function generate_configuration_array() {
        $configuration = array();
        $configuration['stores'] = $this->configstores;
        $configuration['modemappings'] = $this->configmodemappings;
        $configuration['definitions'] = $this->configdefinitions;
        $configuration['definitionmappings'] = $this->configdefinitionmappings;
        $configuration['locks'] = $this->configlocks;
        return $configuration;
    }
416795
protected function _init() {
		$hosts = [];
		foreach ((array) $this->_config['host'] as $host) {
			$host = HostString::parse($host) + [
				'host' => static::DEFAULT_HOST,
				'port' => static::DEFAULT_PORT
			];
			$hosts[] = "{$host['host']}:{$host['port']}";
		}
		if ($this->_config['login']) {
			$this->_config['dsn'] = sprintf(
				'mongodb://%s:%s@%s/%s',
				$this->_config['login'],
				$this->_config['password'],
				implode(',', $hosts),
				$this->_config['database']
			);
		} else {
			$this->_config['dsn'] = sprintf(
				'mongodb://%s',
				implode(',', $hosts)
			);
		}
		parent::_init();

		$this->_operators += [
			'like' => function($key, $value) {
				return new MongoRegex($value);
			},
			'$exists' => function($key, $value) {
				return ['$exists' => (boolean) $value];
			},
			'$type' => function($key, $value) {
				return ['$type' => (integer) $value];
			},
			'$mod' => function($key, $value) {
				$value = (array) $value;
				return ['$mod' => [current($value), next($value) ?: 0]];
			},
			'$size' => function($key, $value) {
				return ['$size' => (integer) $value];
			},
			'$elemMatch' => function($operator, $values, $options = []) {
				$options += [
					'castOpts' => [],
					'field' => ''
				];
				$options['castOpts'] += ['pathKey' => $options['field']];
				$values = (array) $values;

				if (empty($options['castOpts']['schema'])) {
					return ['$elemMatch' => $values];
				}
				foreach ($values as $key => &$value) {
					$value = $options['castOpts']['schema']->cast(
						null, $key, $value, $options['castOpts']
					);
				}
				return ['$elemMatch' => $values];
			}
		];
	}
331466
public function init()
    {
        $extensions = [];

        if (empty($this->extensionClasses) && empty($this->userConfig)) {
            return;
        }

        foreach ($this->extensionClasses as $extensionClass) {
            if (!class_exists($extensionClass)) {
                throw new \InvalidArgumentException(sprintf(
                    'Extension class "%s" does not exist',
                    $extensionClass
                ));
            }

            $extension = new $extensionClass();

            if (!$extension instanceof ExtensionInterface) {
                throw new \InvalidArgumentException(sprintf(
                    // add any manually specified extensions
                    'Extension "%s" must implement the PhpBench\\Extension interface',
                    get_class($extension)
                ));
            }

            $extensions[] = $extension;

            $this->config = array_merge(
                $this->config,
                $extension->getDefaultConfig()
            );
        }

        $diff = array_diff(array_keys($this->userConfig), array_keys($this->config));

        if ($diff) {
            throw new \InvalidArgumentException(sprintf(
                'Unknown configuration keys: "%s". Permitted keys: "%s"',
                implode('", "', $diff), implode('", "', array_keys($this->config))
            ));
        }

        $this->config = array_merge(
            $this->config,
            $this->userConfig
        );

        foreach ($extensions as $extension) {
            $extension->load($this);
        }
    }