从当前路由规则中匹配规则
@param  array  $rules 当前请求方法的路由规则
@param  string $url   当前请求url
@return array|null    匹配结果
761053
private function match($rules, $url)
    {
        //大小写不敏感匹配
        if ($this->config['ci']) {
            $url        = strtolower($url);
            $rules['S'] = array_change_key_case($rules['S'], CASE_LOWER);
            $rules['D'] = array_change_key_case($rules['D'], CASE_LOWER);
        }

        if (isset($rules['S'][$url])) {
            $rule   = $rules['S'][$url]; //匹配静态规则
            $params = [];
            $type   = 'static'; //debug用
        } else {
            $match = false; //匹配动态规则
            foreach ($rules['D'] as $pattern => $rule) {
                if (preg_match_all($pattern, $url, $params, PREG_SET_ORDER)) {
                    $match = true;
                    break; //匹配动态规则
                }
            }
            if (!$match) {
                return null; //未匹配到规则
            }
            $params = $params[0];
            unset($params[0]);
            $params = array_combine($rule['params'], $params); //处理动态参数
            $type   = 'dynamic';
        }

        if (isset($rule['pre'])) {
            $rule['main'] = array_merge($rules['PRE'][$rule['pre']], $rule['main']); //存在前置执行
        }
        if (isset($rule['post'])) {
            $rule['main'] = array_merge($rule['main'], $rules['POST'][$rule['post']]); //存在后置执行
        }
        if ($this->Debug) {
            $this->Debug->type($type);
        }
        return ['rules' => $rule['main'], 'params' => $params];
    }
175347
public function make(array $rules, AppliesToResource $resource=null)
    {

        if (!$rules) {
            return null;
        }

        $validator = $this->createObject(GenericValidator::class)->setRules($rules);
        return $this->configureAndReturn($validator, $rules, $resource);
    }
626118
protected function getRuleArgument($rule)
    {
        $exploded = explode(':', $rule);

        return isset($exploded[1]) ?
            array('rule' => $exploded[0], 'argument' => $exploded[1]) : null;
    }
799885
public function rules(array $rules)
    {
        foreach ($rules as $ruleType => $params) {
            if (\is_array($params)) {
                foreach ($params as $innerParams) {
                    $innerParams = (array) $innerParams;
                    $this->rule($ruleType, ...$innerParams);
                }
            } else {
                $this->rule($ruleType, $params);
            }
        }

        return $this;
    }
159341
protected function validateAttribute($rules) {
        $validator = new Validator();
        foreach ($rules as $key => $item) {
            if (!$this->isNewRecord && !$this->hasAttribute($key)) {
                continue;
            }
            $item = $validator->converterRule($item);
            // 增加必须判断
            if (!$this->hasAttribute($key)
                && !isset($item['rules']['required'])) {
                continue;
            }
            $value = $this->getAttributeValue($key);
            foreach ($item['rules'] as $rule => $args) {
                if (is_callable($args)) {
                    if (false !== call_user_func($args, $value)) {
                        continue;
                    }
                    $validator->messages()->add($key, $validator->getMessage($key, $rule, $item['message']));
                    continue;
                }
                if (method_exists($this, $rule)) {
                    if (false !== call_user_func([$this, $rule], $value)) {
                        continue;
                    }
                    $validator->messages()->add($key, $validator->getMessage($key, $rule, $item['message']));
                    continue;
                }
                if (Validator::buildRule($rule, (array)$args)
                    ->validate($value)) {
                    continue;
                }
                $validator->messages()->add($key, $validator->getMessage($key, $rule, $item['message']));
            }
        }
        $this->setError($validator->messages()->getMessages());
        return !$this->hasError();
    }
153330
public function addRules(array $rules): array
    {
        // serialize the rules altogether

        $this->getSerializer()->clearBlocksWithStart()->clearBlocksWithEnd();

        $indexes = [];
        foreach ($rules as $name => $rule) {
            assert($rule instanceof RuleInterface);

            $ruleName = $rule->getName();
            if (empty($ruleName) === true) {
                $ruleName = $name;
            }

            $block          = $rule->setName($ruleName)->enableCapture()->toBlock();
            $indexes[$name] = $this->getSerializer()->addBlock($block);
        }

        $ruleIndexes = [
            static::RULES_ARRAY_INDEXES       => $indexes,
            static::RULES_ARRAY_START_INDEXES => $this->getSerializer()->getBlocksWithStart(),
            static::RULES_ARRAY_END_INDEXES   => $this->getSerializer()->getBlocksWithEnd(),
        ];

        $this->getSerializer()->clearBlocksWithStart()->clearBlocksWithEnd();

        // sometimes (e.g. update in relationship) an individual validation rule is needed
        // so we should have a second serialization of each rule individually

        $individualRules = [];
        foreach ($rules as $name => $rule) {
            $individualRules[$name] = $this->addRule($rule);
        }
        $ruleIndexes[static::RULES_ARRAY_SINGLE_INDEXES] = $individualRules;

        return $ruleIndexes;
    }
981917
public function setRules(array $rules)
    {
        $this->rules = [];
        foreach ($rules as $key => $value) {
            if (is_int($key)) {
                $routeRegex  = $value;
                $permissions = [];
            } else {
                $routeRegex  = $key;
                $permissions = (array) $value;
            }
            $this->rules[$routeRegex] = $permissions;
        }
    }
1167171
protected function getValidationRulesFromElements(array $rules = [])
    {
        $this->getElements()->onlyActive()->each(function ($element) use (&$rules) {
            $element = $this->getElementContainer($element);

            if ($element instanceof Validable) {
                $rules += $element->getValidationRules();
            }
        });

        return $rules;
    }
800614
protected function parse_array_rules( array $rules ) {
		$parse_rules = [];

		foreach ( $rules as $key => $value ) {
			if ( is_int( $key ) ) {
				$parse_rules[] = [ $this->normalize( $value ), [] ];
				continue;
			}

			$key = $this->normalize( $key );

			if ( ! is_array( $value ) ) {
				$value = [ $value ];
			}

			$parse_rules[] = [ $key, $this->wrap_parameters( $key, $value ) ];
		}

		return $parse_rules;
	}
913433
protected function parserValidationRules($rules, $id = null)
    {

        if($id === null)
        {
            return $rules;
        }

        array_walk($rules, function(&$rules, $field) use ($id)
        {
            if(!is_array($rules))
            {
                $rules = explode("|", $rules);
            }

            foreach($rules as $ruleIdx => $rule)
            {
                // get name and parameters
                @list($name, $params) = array_pad(explode(":", $rule), 2, null);

                // only do someting for the unique rule
                if(strtolower($name) != "unique") {
                    continue; // continue in foreach loop, nothing left to do here
                }

                $p = array_map("trim", explode(",", $params));

                // set field name to rules key ($field) (laravel convention)
                if(!isset($p[1])) {
                    $p[1] = $field;
                }

                // set 3rd parameter to id given to getValidationRules()
                $p[2] = $id;

                $params = implode(",", $p);
                $rules[$ruleIdx] = $name.":".$params;
            }
        });

        return $rules;
    }
473727
protected function parseUrl($url)
    {
        $depr = $this->rule->getConfig('app.pathinfo_depr');
        $bind = $this->rule->getRouter()->getBind();

        if (!empty($bind) && preg_match('/^[a-z]/is', $bind)) {
            $bind = str_replace('/', $depr, $bind);
            // 如果有模块/控制器绑定
            $url = $bind . ('.' != substr($bind, -1) ? $depr : '') . ltrim($url, $depr);
        }

        list($path, $var) = $this->rule->parseUrlPath($url);

        return $path;

//        // 解析模块
//        $module = array_shift($path);
//
//        if ($this->param['auto_search']) {
//            $controller = $this->autoFindController($module, $path);
//        } else {
//            // 解析控制器
//            $controller = !empty($path) ? array_shift($path) : null;
//        }
//
//        // 解析操作
//        $action = !empty($path) ? array_shift($path) : null;
//
//        // 解析额外参数
//        if ($path) {
//            if ($this->rule->getConfig('url_param_type')) {
//                $var += $path;
//            } else {
//                preg_replace_callback('/(\w+)\|([^\|]+)/', function ($match) use (&$var) {
//                    $var[$match[1]] = strip_tags($match[2]);
//                }, implode('|', $path));
//            }
//        }
//
//        $panDomain = Request::panDomain();
//
//        if ($panDomain && $key = array_search('*', $var)) {
//            // 泛域名赋值
//            $var[$key] = $panDomain;
//        }
//
//        // 设置当前请求的参数
//        Request::setRouteVars($var);
//
//        // 封装路由
//        $route = [$module, $controller, $action];
//
//        if ($this->hasDefinedRoute($route, $bind)) {
//            throw new HttpException(404, 'invalid request:' . str_replace('|', $depr, $url));
//        }
//
//        return $route;
    }
301613
public function getPotentialRules($uri)
    {
        //
        // Try to match uri with rule without route params
        //

        $redirectRules = RedirectRule::where('origin', $uri)->get();

        if ($redirectRules->isNotEmpty()) {
            return $redirectRules;
        }

        //
        // Try to match uri with rule with url params:
        //

        // Search only rules with params but without optional params
        $query = RedirectRule::where('origin', 'LIKE', '%{%')
            ->where('origin', 'NOT LIKE', '%?}%');

        // Narrow potential matches by matching number of url segments
        // (by matching number of slashes)
        $slashesCount = substr_count($uri, '/');
        $rawWhere = \DB::raw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))");
        $query = $query->where($rawWhere, $slashesCount);

        // Ordering
        $query
            // Route with lesser number of parameters will have top priority
            ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))")
            // Rules with params nearer end of route will have last priority
            ->orderByRaw("INSTR(origin, '{') DESC");

        // Get collection of potential rules
        $potentialRules = $query->get();

        if ($potentialRules->isNotEmpty()) {
            return $potentialRules;
        }

        //
        // Try to match uri with rule with optional url params:
        //

        // Search only rules with optional params
        $query = RedirectRule::where('origin', 'LIKE', '%?}%');

        // Ordering
        $query
            // Route with less segments will have top priority
            ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '/', ''))")
            // Route with lesser number of parameters will have next priority
            ->orderByRaw("LENGTH(origin) - LENGTH(REPLACE(origin, '{', ''))")
            // Rules with params nearer end of route will have last priority
            ->orderByRaw("INSTR(origin, '{') DESC");

        return $query->get();
    }
1263505
protected function getRulesContent(array $rules = null, $level = 0)
    {
        if ($level === 0) {
            $rules = $this->getStyleSheet()->getRules();
            $this->errorMessages = [];
        }

        // Get format options
        $options = $this->getOptions($level);

        $content = "";
        foreach ($rules as $rule) {
            if ($options["BaseAddComments"] === true) {
                if (!($rule instanceof CharsetRule)) {
                    $comments = $rule->getComments();
                    foreach ($comments as $comment) {
                        $content .= $options["CommentIntend"] . $comment . $options["CommentLineBreak"];
                    }
                }
            }

            // Skip invalid rules
            if ($rule->getIsValid() === false) {
                // Copy error to the writer
                foreach ($rule->getValidationErrors() as $validationError) {
                    $this->errorMessages[] = $validationError;
                }
                continue;
            }

            if ($rule instanceof CharsetRule) {
                // @charset must be at the beginning of the content
                if ($content === "") {
                    $content .= "@" . ((string)$rule->getVendorPrefix()) . "charset \"" . $rule->getValue() . "\";" . $options["CharsetLineBreak"];
                }
            } elseif ($rule instanceof ImportRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "import ";
                $content .= "url(\"" . Url::escapeUrl($rule->getUrl()) . "\")";

                $mediaQueryConcat = "";
                foreach ($rule->getQueries() as $mediaQuery) {
                    $content .= $mediaQueryConcat;
                    if ($mediaQuery->getIsOnly() === true) {
                        $content .= " only";
                    } else if ($mediaQuery->getIsNot() === true) {
                        $content .= " not";
                    }
                    // Filter default type "all"
                    if ($mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                        $content .= " " . $mediaQuery->getType();
                    }
                    $conditions = $mediaQuery->getConditions();
                    if (count($conditions) > 0) {
                        if ($mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                            $content .= " and";
                        }
                        $content .= " (";
                        $mediaConditionConcat = "";
                        foreach ($conditions as $condition) {
                            if ($condition->getIsValid() === true) {
                                $content .= $mediaConditionConcat . $condition->getValue();
                                $mediaConditionConcat = ") and (";
                            } else {
                                // Copy error to the writer
                                foreach ($condition->getValidationErrors() as $validationError) {
                                    $this->errorMessages[] = $validationError;
                                }
                            }
                        }
                        $content .= ")";
                    }
                    $mediaQueryConcat = ",";
                }
                $content .= ";" . $options["ImportLineBreak"];
            } elseif ($rule instanceof NamespaceRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "namespace";
                $prefix = $rule->getPrefix();
                if (!empty($prefix)) {
                    $content .= " " . $prefix;
                }
                $content .= " url(\"" . Url::escapeUrl($rule->getName()) . "\")";
                $content .= ";" . $options["NamespaceLineBreak"];
            } elseif ($rule instanceof DocumentRule) {
                // Prepare rule start content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "document";

                // Prepare rule filter content
                $concat = " ";
                $url = $rule->getUrl();
                if (!empty($url)) {
                    $ruleStartContent .= $concat . "url($url)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $urlPrefix = $rule->getUrlPrefix();
                if (!empty($urlPrefix)) {
                    $ruleStartContent .= $concat . "url-prefix($urlPrefix)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $domain = $rule->getDomain();
                if (!empty($domain)) {
                    $ruleStartContent .= $concat . "domain($domain)";
                    $concat = $options["DocumentFilterSeparator"];
                }
                $regexp = $rule->getRegexp();
                if (!empty($regexp)) {
                    $ruleStartContent .= $concat . "regexp($regexp)";
                }

                // Prepare rule content
                $ruleRuleContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRuleContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["DocumentRuleSetOpen"];
                    $content .= $ruleRuleContent;
                    $content .= $options["DocumentRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty document at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof FontFaceRule) {
                // Prepare rule start content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "font-face";
                $ruleStartContent .= $options["FontFaceRuleSetOpen"];

                // Prepare rule declarations content
                /** @var FontFaceDeclaration[] $declarations */
                $declarations = $rule->getDeclarations();
                for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                    if ($declarations[$i]->getIsValid() === true) {
                        if ($ruleStartContent !== "") {
                            $content .= $ruleStartContent;
                            $ruleStartContent = "";
                        }
                        if ($options["BaseAddComments"] === true) {
                            $comments = $declarations[$i]->getComments();
                            foreach ($comments as $comment) {
                                $content .= $options["FontFaceRuleSetIntend"] . $comment . $options["FontFaceCommentLineBreak"];
                            }
                        }
                        $content .= $options["FontFaceDeclarationIntend"] . $declarations[$i]->getProperty();
                        $content .= $options["FontFaceDeclarationSeparator"] . $declarations[$i]->getValue();
                        if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                            $content .= ";";
                        }
                        $content .= $options["FontFaceDeclarationLineBreak"];
                    } else {
                        // Copy error to the writer
                        foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid declarations set
                if ($ruleStartContent === "") {
                    $content .= $options["FontFaceRuleSetClose"];
                }
            } elseif ($rule instanceof KeyframesRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "keyframes " ;
                $ruleStartContent .= $rule->getIdentifier();
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["KeyframesRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["KeyframesRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty keyframes at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof MediaRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "media";
                $mediaQueryConcat = " ";
                $ignoreAllType = true;
                foreach ($rule->getQueries() as $mediaQuery) {
                    $ruleStartContent .= $mediaQueryConcat;
                    if ($mediaQuery->getIsOnly() === true) {
                        $ruleStartContent .= "only ";
                        $ignoreAllType = false;
                    } elseif ($mediaQuery->getIsNot() === true) {
                        $ruleStartContent .= "not ";
                        $ignoreAllType = false;
                    }

                    if ($ignoreAllType === false || $mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                        $ruleStartContent .= $mediaQuery->getType();
                    }
                    $conditions = $mediaQuery->getConditions();
                    if (count($conditions) > 0) {
                        if ($ignoreAllType === false || $mediaQuery->getType() !== MediaQuery::TYPE_ALL) {
                            $ruleStartContent .= " and ";
                        }
                        $ruleStartContent .= "(";
                        $mediaConditionConcat = "";
                        foreach ($conditions as $condition) {
                            if ($condition->getIsValid() === true) {
                                $ruleStartContent .= $mediaConditionConcat . $condition->getValue();
                                $mediaConditionConcat = ") and (";
                            } else {
                                // Copy error to the writer
                                foreach ($condition->getValidationErrors() as $validationError) {
                                    $this->errorMessages[] = $validationError;
                                }
                            }
                        }
                        $ruleStartContent .= ")";
                    }
                    $mediaQueryConcat = $options["MediaQuerySeparator"];
                    $ignoreAllType = false;
                }
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["MediaRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["MediaRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty media at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof PageRule) {
                $content .= $options["BaseIntend"];
                $content .= "@" . ((string)$rule->getVendorPrefix()) . "page";

                $selector = $rule->getSelector()->getValue();
                if ($selector !== PageSelector::SELECTOR_ALL) {
                    $content .= " " . $selector;
                }
                $content .= $options["PageRuleSetOpen"];

                /** @var PageDeclaration[] $declarations */
                $declarations = $rule->getDeclarations();
                for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                    if ($declarations[$i]->getIsValid() === true) {
                        if ($options["BaseAddComments"] === true) {
                            $comments = $declarations[$i]->getComments();
                            foreach ($comments as $comment) {
                                $content .= $options["PageDeclarationIntend"] . $comment . $options["PageCommentLineBreak"];
                            }
                        }
                        $content .= $options["PageDeclarationIntend"] . $declarations[$i]->getProperty();
                        $content .= $options["PageDeclarationSeparator"] . $declarations[$i]->getValue();
                        if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                            $content .= ";";
                        }
                        $content .= $options["PageDeclarationLineBreak"];
                    } else {
                        // Copy error to the writer
                        foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                $content .= $options["PageRuleSetClose"];
            } elseif ($rule instanceof SupportsRule) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleStartContent .= "@" . ((string)$rule->getVendorPrefix()) . "supports ";
                $conditions = $rule->getConditions();
                if (count($conditions) > 0) {
                    $ruleStartContent .= "(";
                    $supportConditionConcat = "";
                    foreach ($conditions as $condition) {
                        if ($condition->getIsValid() === true) {
                            $ruleStartContent .= $supportConditionConcat . $condition->getValue();
                            $supportConditionConcat = ") and (";
                        } else {
                            // Copy error to the writer
                            foreach ($condition->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }
                    $ruleStartContent .= ")";
                }
                $ruleRulesContent = $this->getRulesContent($rule->getRules(), $level + 1);

                // Only add the content if valid rules set
                if ($ruleRulesContent !== "") {
                    $content .= $ruleStartContent;
                    $content .= $options["SupportsRuleSetOpen"];
                    $content .= $ruleRulesContent;
                    $content .= $options["SupportsRuleSetClose"];
                } else {
                    $this->errorMessages[] = "Empty supports at-rule '$ruleStartContent' ignored.";
                }
            } elseif ($rule instanceof StyleRuleSet) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleSelectorContent = "";
                $concat = "";
                foreach ($rule->getSelectors() as $selector) {
                    if ($selector->getIsValid() === true) {
                        $ruleSelectorContent .= $concat . $selector->getValue();
                        $concat = $options["StyleSelectorSeparator"];
                    } else {
                        // Copy error to the writer
                        foreach ($selector->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid selectors set
                if ($ruleSelectorContent !== "") {
                    $ruleStartContent .= $ruleSelectorContent;
                    $ruleStartContent .= $options["StyleDeclarationsOpen"];

                    // Prepare rule declaration content
                    /** @var StyleDeclaration[] $declarations */
                    $ruleDeclarationContent = "";
                    $declarations = $rule->getDeclarations();
                    for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                        if ($declarations[$i]->getIsValid() === true) {
                            if ($options["BaseAddComments"] === true) {
                                $comments = $declarations[$i]->getComments();
                                foreach ($comments as $comment) {
                                    $ruleDeclarationContent .= $options["StyleDeclarationIntend"] . $comment . $options["StyleCommentLineBreak"];
                                }
                            }
                            $important = $declarations[$i]->getIsImportant() ? " !important" : "";
                            $ruleDeclarationContent .= $options["StyleDeclarationIntend"] . $declarations[$i]->getProperty();
                            $ruleDeclarationContent .= $options["StyleDeclarationSeparator"] . $declarations[$i]->getValue() . $important;
                            if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                                $ruleDeclarationContent .= ";";
                            }
                            $ruleDeclarationContent .= $options["StyleDeclarationLineBreak"];
                        } else {
                            // Copy error to the writer
                            foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }

                    // Only add the content if valid declarations set
                    if ($ruleDeclarationContent !== "") {
                        $content .= $ruleStartContent;
                        $content .= $ruleDeclarationContent;
                        $content .= $options["StyleDeclarationsClose"];
                    } else {
                        $this->errorMessages[] = "Empty style rule set '$ruleSelectorContent' ignored.";
                    }
                }
            } elseif ($rule instanceof KeyframesRuleSet) {
                // Prepare rule content
                $ruleStartContent = $options["BaseIntend"];
                $ruleSelectorContent = "";
                $concat = "";
                foreach ($rule->getKeyframes() as $keyframe) {
                    if ($keyframe->getIsValid() === true) {
                        $ruleSelectorContent .= $concat . $keyframe->getValue();
                        $concat = $options["KeyframesSelectorSeparator"];
                    } else {
                        // Copy error to the writer
                        foreach ($keyframe->getValidationErrors() as $validationError) {
                            $this->errorMessages[] = $validationError;
                        }
                    }
                }

                // Only add the content if valid selectors set
                if ($ruleSelectorContent !== "") {
                    $ruleStartContent .= $ruleSelectorContent;
                    $ruleStartContent .= $options["KeyframesDeclarationsOpen"];

                    /** @var KeyframesDeclaration[] $declarations */
                    $ruleDeclarationContent = "";
                    $declarations = $rule->getDeclarations();
                    for ($i = 0, $j = count($declarations); $i < $j; $i++) {
                        if ($declarations[$i]->getIsValid() === true) {
                            $ruleDeclarationContent .= $options["KeyframesDeclarationIntend"] . $declarations[$i]->getProperty();
                            $ruleDeclarationContent .= $options["KeyframesDeclarationSeparator"] . $declarations[$i]->getValue();
                            if ($options["BaseLastDeclarationSemicolon"] === true || $i < ($j - 1)) {
                                $ruleDeclarationContent .= ";";
                            }
                            $ruleDeclarationContent .= $options["KeyframesDeclarationLineBreak"];
                        } else {
                            // Copy error to the writer
                            foreach ($declarations[$i]->getValidationErrors() as $validationError) {
                                $this->errorMessages[] = $validationError;
                            }
                        }
                    }

                    // Only add the content if valid declarations set
                    if ($ruleDeclarationContent !== "") {
                        $content .= $ruleStartContent;
                        $content .= $ruleDeclarationContent;
                        $content .= $options["KeyframesDeclarationsClose"];
                    } else {
                        $this->errorMessages[] = "Empty keyframes rule set '$ruleSelectorContent' ignored.";
                    }
                }
            }
        }

        // Save complete style sheet content in property
        if ($level === 0) {
            $this->content = $content;
        }

        return $content;
    }
1081874
public function forceNext ($url, $rule = self::NEXT_FORWARD) {
		$this->rule->next[0][0] = $url;
		$this->rule->next[0][1] = $rule;
	}
556941
protected function extractInputFromRules(Request $request, array $rules)
    {
        return $request->only(collect($rules)->keys()->map(function ($rule) {
            return Str::contains($rule, '.') ? explode('.', $rule)[0] : $rule;
        })->unique()->toArray());
    }
838017
public function extract_first($rules)
    {
        if ($this->_nodes) {
            $selector = new Selector($this->_document, current($this->_nodes));
            return $selector->extract($rules);
        } else {
            return [];
        }
    }
869375
public static function parse($rules)
    {
        if ($rules instanceof RuleContract) {
            return [$rules, []];
        }

        if (is_array($rules)) {
            $rules = static::parseArrayRule($rules);
        } else {
            $rules = static::parseStringRule($rules);
        }

        $rules[0] = static::normalizeRule($rules[0]);

        return $rules;
    }