Merge a set of rules into this collection

@param array|Ruleset $rules     2D array of rule definitions, or instance of Ruleset
@param bool          $overwrite Whether to overwrite scalar rules (e.g. boolean rules)
430016
public function merge($rules, $overwrite = true)
	{
		if (!is_array($rules)
		 && !($rules instanceof self))
		{
			throw new InvalidArgumentException('merge() expects an array or an instance of Ruleset');
		}

		foreach ($rules as $action => $value)
		{
			if (is_array($value))
			{
				foreach ($value as $tagName)
				{
					$this->$action($tagName);
				}
			}
			elseif ($overwrite || !isset($this->items[$action]))
			{
				$this->$action($value);
			}
		}
	}
664196
public function setRules($rules)
    {
        foreach ($rules as $ruleName => $rule) {
            $this->setRule($ruleName, $rule);
        }
    }
669702
public boolean copyChanges(final TreeRule rule, final boolean overwrite) {
    if (rule == null) {
      throw new IllegalArgumentException("Cannot copy a null rule");
    }
    if (tree_id != rule.tree_id) {
      throw new IllegalArgumentException("Tree IDs do not match");
    }
    if (level != rule.level) {
      throw new IllegalArgumentException("Levels do not match");
    }
    if (order != rule.order) {
      throw new IllegalArgumentException("Orders do not match");
    }
    
    if (overwrite || (rule.changed.get("type") && type != rule.type)) {
      type = rule.type;
      changed.put("type", true);
    }
    if (overwrite || (rule.changed.get("field") && !field.equals(rule.field))) {
      field = rule.field;
      changed.put("field", true);
    }
    if (overwrite || (rule.changed.get("custom_field") && 
        !custom_field.equals(rule.custom_field))) {
      custom_field = rule.custom_field;
      changed.put("custom_field", true);
    }
    if (overwrite || (rule.changed.get("regex") && !regex.equals(rule.regex))) {
      // validate and compile via the setter
      setRegex(rule.regex);
    }
    if (overwrite || (rule.changed.get("separator") && 
        !separator.equals(rule.separator))) {
      separator = rule.separator;
      changed.put("separator", true);
    }
    if (overwrite || (rule.changed.get("description") &&
        !description.equals(rule.description))) {
      description = rule.description;
      changed.put("description", true);
    }
    if (overwrite || (rule.changed.get("notes") && !notes.equals(rule.notes))) {
      notes = rule.notes;
      changed.put("notes", true);
    }
    if (overwrite || (rule.changed.get("regex_group_idx") && 
        regex_group_idx != rule.regex_group_idx)) {
      regex_group_idx = rule.regex_group_idx;
      changed.put("regex_group_idx", true);
    }
    if (overwrite || (rule.changed.get("display_format") && 
        !display_format.equals(rule.display_format))) {
      display_format = rule.display_format;
      changed.put("display_format", true);
    }
    for (boolean has_changes : changed.values()) {
      if (has_changes) {
        return true;
      }
    }
    return false;
  }
1177399
public function setConfig(array $config, $overwrite = false)
    {
        if ($overwrite) {
            $this->config = $this->mergeConfig($this->config, $config);
        } else {
            $this->config = $this->mergeConfig($config, $this->config);
        }
    }
822736
public function getRules($overrideRules = [])
    {
        $fieldRules = $this->formHelper->mergeFieldsRules($this->fields);

        return array_merge($fieldRules->getRules(), $overrideRules);
    }
150526
public function addMetaData($key, $value, $overwrite = true)
    {
        $this->meta[$key] = isset($this->meta[$key])
            ? $overwrite ? $value : $this->meta[$key]
            : $value;

        return $this;
    }
918082
private function sortRules(&$rules)
    {
        sort($rules);
        usort($rules, function ($a, $b) {
            return strlen($a) - strlen($b);
        });
    }
1087497
public function each( $attribute, $rules )
	{
		$data = Arr::dot( $this->initializeAttributeOnData( $attribute ) );

		$pattern = str_replace( '\*', '[^\.]+', preg_quote( $attribute ) );

		$data = array_merge( $data, $this->extractValuesForWildcards( $data, $attribute ) );

		foreach ( $data as $key => $value )
		{
			if ( Str::startsWith( $key, $attribute ) || (bool) preg_match( '/^' . $pattern . '\z/', $key ) )
			{
				foreach ( (array) $rules as $ruleKey => $ruleValue )
				{
					if ( !is_string( $ruleKey ) || Str::endsWith( $key, $ruleKey ) )
					{
						$this->implicitAttributes[$attribute][] = $key;

						$this->mergeRules( $key, $ruleValue );
					}
				}
			}
		}
	}
783118
public function merge($newValues, $override = true)
    {
        foreach ($newValues as $key => $value) {
            // If the key doesn't exist yet,
            // we can simply set it.
            if (!array_key_exists($key, $this)) {
                $this[$key] = $value;
                continue;
            }

            // We already know this value exists
            // so if we're in conservative mode
            // we can skip this key
            if ($override === false) {
                continue;
            }

            // Merge the values only if
            // both values are arrays
            if (is_array($this[$key]) && is_array($value)) {
                $this[$key] = array_replace_recursive($this[$key], $value);
            } else {
                $this[$key] = $value;
            }
        }
    }
1313859
public function mergeRules($attribute, $rules)
    {
        $current = isset($this->rules[$attribute]) ? $this->rules[$attribute] : [];

        $merge = head($this->explodeRules([$rules]));

        $this->rules[$attribute] = array_merge($current, $merge);
    }
1178607
public function load($overwrite = false)
	{
		$paths = $this->find_file();

		$lang = array();

		foreach ($paths as $path)
		{
			$lang = $overwrite ?
				array_merge($lang, $this->load_file($path)) :
				\Arr::merge($lang, $this->load_file($path));
		}

		return $lang;
	}
862541
public function append($append = [], $override = false)
    {
        $this->append = $override ? $append : array_merge($this->append, $append);

        return $this;
    }
1202542
function merge(Style $style) {
    //treat the !important attribute
    //if old rule has !important attribute, override with new rule only if
    //the new rule is also !important
    foreach($style->_props as $prop => $val ) {
      if (isset($style->_important_props[$prop])) {
        $this->_important_props[$prop] = true;
        //see __set and __get, on all assignments clear cache!
        $this->_prop_cache[$prop] = null;
        $this->_props[$prop] = $val;
      } else if ( !isset($this->_important_props[$prop]) ) {
        //see __set and __get, on all assignments clear cache!
        $this->_prop_cache[$prop] = null;
        $this->_props[$prop] = $val;
      }
    }

    if ( isset($style->_props["font_size"]) )
      $this->__font_size_calculated = false;
  }
960899
public function rules($rules)
    {
        foreach ($rules as $rule => $field) {
            if (is_array($field) && is_array($field[0])) {
                foreach ($field as $params) {
                    array_unshift($params, $rule);
                    call_user_func_array([$this, 'rule'], $params);
                }
            } else {
                $this->rule($rule, $field);
            }
        }
        return $this;
    }
200944
public function set( $key, $value, $overwrite = true )
    {
        Option::set( $this->_map, $this->_hashKey( $key ), $value, $overwrite );

        return $this;
    }
151998
protected function addIteratedValidationRules($attribute, $ruleSet = [], $messages = [])
    {
        foreach ($ruleSet as $field => $rules) {
            $rules = str_replace('{parent}', rtrim($attribute, '.'), $rules);
            $rules = str_replace('{index}.', $attribute, $rules);
            $rules = is_string($rules) ? explode('|', $rules) : $rules;

            //If it contains nested iterated items, recursively add validation rules for them too
            if (isset($rules['iterate'])) {
                $this->iterateNestedRuleSet($attribute.$field, $rules);
                unset($rules['iterate']);
            }

            $this->mergeRules($attribute.$field, $rules);
        }
        $this->addIteratedValidationMessages($attribute, $messages);
    }
445247
public function addRules(array $rules)
    {
        foreach ($rules as $rule) {
            if (is_array($rule)) {
                $this->addRules($rule);
            } else {
                $this->addRule($rule);
            }
        }

        return $this;
    }