Creates an chained hashtable using the lookup char as the key
@param array $rules
553897
protected function indexRules(array $rules)
    {        
        $this->indexedRules = array();
        
        foreach($rules as $rule){
            if(isset($this->indexedRules[$rule[self::LOOKUP_CHAR]])){
                $this->indexedRules[$rule[self::LOOKUP_CHAR]][] = $rule;
            } else {
                $this->indexedRules[$rule[self::LOOKUP_CHAR]] = array($rule);
            }
        }       
    }
1267674
public function addRules(Rule ...$rules): MutableQuery
    {
        $cloned = clone $this;

        $activeRules = iterator_to_array($this->rules);
        $activeRules = array_merge($activeRules, $rules);

        $cloned->rules = new RuleCollection($this->rules->getJoinKeyword(), ...$activeRules);

        return $cloned;
    }
1142649
public function addMultiple($rules)
    {
        foreach ($rules as $singleRule) {
            // make sure the rule is an array (the parameters of subsequent calls);
            $singleRule = is_array($singleRule) ? $singleRule : array(
                $singleRule
            );
            call_user_func_array(
                array(
                    $this,
                    'add'
                ),
                $singleRule
            );
        }

        return $this;
    }
927031
public function setPasswordStrengthRules($rules)
    {
        $this->_passwordStrengthRules = [];
        if (!is_array($rules)) {
            return;
        }
        foreach ($rules as $rule) {
            $this->_passwordStrengthRules[] = array_merge(['newPassword'], $rule);
        }
    }
834930
public function setRulesFor($key, $rules)
    {
        if (is_array($rules) || is_string($rules))
            $this->_rules[$key] = $rules;

        return $this;
    }
772661
public function applyRuleOptions($rules)
    {
        foreach ($rules as $key => $rule) {
            foreach ($this->_ruleOptions as $name => $value) {
                $rules[$key][$name] = $value;
            }
        }

        return $rules;
    }
1302282
public function addRules($rules)
    {
        if ($rules instanceof RiskyRulesAwareInterface && $rules->isRisky()) {
            $this->setRiskyAllowed(true);
        }

        if ($rules instanceof \Traversable) {
            $rules = iterator_to_array($rules);
        }

        if (!is_array($rules)) {
            throw new \InvalidArgumentException('Expected rules to be an iterable.');
        }

        $rules = array_replace($this->getRules(), $rules);

        $this->setRules($rules);

        return $this;
    }
16366
protected function setEntityRules($rules = [])
    {
        $this->entityLocalRules = $rules;
        $cache = $this->getCache();
        if ($cache) {
            $tagDependency = new TagDependency(
                ['tags' => [$this->getEntityRulesCacheTag()]]
            );
            $cache->set($this->getEntityRulesCacheKey(), $rules, 0, $tagDependency);
        }
    }
387273
public function setRules(array $rules): self
    {
        assert(empty($rules) === false);

        $this->rules = $rules;

        return $this;
    }
1320055
public function optimize(array $rules): array
    {
        assert(empty($rules) === false);

        $ruleId       = 0;
        $rawTargets   = [];
        $encodedRules = [];
        foreach ($rules as $rule) {
            /** @var RuleInterface $rule */
            $rawTargets[$ruleId]   = $rule->getTarget();
            $encodedRules[$ruleId] = Encoder::encodeRule($rule);
            $ruleId++;
        }

        $callable         = static::METHOD;
        $optimizedTargets = $this->optimizeTargets($rawTargets);

        /** @var callable|array $callable */
        assert($callable !== null && is_array($callable) === true &&
            is_callable($callable) === true && count($callable) === 2 &&
            is_string($callable[0]) === true && is_string($callable[1]) === true);

        return [
            static::INDEX_TARGETS  => $optimizedTargets,
            static::INDEX_RULES    => $encodedRules,
            static::INDEX_CALLABLE => $callable,
        ];
    }
578783
public function make(array $rules, AppliesToResource $resource=null)
    {

        if (!$resource) {
            return null;
        }

        $rules = array_merge($this->detectRules($resource), $rules);

        return $this->createObject(GenericValidator::class)->setRules($rules);

    }
15980
public function add_rules( array $rules ) {
		foreach ( $rules as $name => $rule ) {
			$this->add_rule( $name, $rule );
		}

		return $this;
	}
827692
public function parse($rules): Rule\Set
    {
        $isArray = is_array($rules);
        $isAssoc = $isArray && self::isAssociative($rules);
        $set = null;
        if (is_string($rules) || is_object($rules) || $isAssoc) {
            $set = $this->getRule($rules);
        } elseif ($isArray) {
            foreach ($rules as $v) {
                $toAdd = $this->getRule($v);
                $set = $set === null ? $toAdd : $set->merge($toAdd);
            }
        }
        return $set ?? new Rule\Set();
    }
1260517
protected static function initMatrix(array $rules)
	{
		$matrix   = [];
		$tagNames = array_keys($rules);

		foreach ($rules as $tagName => $tagRules)
		{
			$matrix[$tagName]['allowedChildren']    = array_fill_keys($tagNames, 0);
			$matrix[$tagName]['allowedDescendants'] = array_fill_keys($tagNames, 0);
		}

		return $matrix;
	}
81499
public function parse( $rules ) {
		if ( is_array( $rules ) ) {
			return $this->parse_array_rules( $rules );
		}

		return $this->parse_string_rules( $rules );
	}
675205
protected function normalizeValidationRuleSourceDataFromConfig(array $rules)
    {
        // Remove entries to be ignored and excluded
        $filteredRules = array_filter($rules, function ($rule, $key) {

            return  false !== $rule
                &&  ! empty($rule)
                &&  ! (is_string($rule) && is_numeric($key));

        }, ARRAY_FILTER_USE_BOTH);

        return $this->normalizeValidationRuleSourceData($filteredRules);
    }
986961
protected function setRules( array $rules )
	{
		foreach( $rules as $key => $rule ) {
			$rules[ $key ] = is_string( $rule ) ? explode( '|', $rule ) : $rule;
		}

		$this->rules = $rules;

		return $this;
	}