collection = new NormalizedList; $this->configurator->tags->add($this->tagName)->attributes->add($this->attrName); } public function asConfig() { if (!\count($this->collection)) return; $config = [ 'attrName' => $this->attrName, 'tagName' => $this->tagName ]; if (!empty($this->onlyFirst)) $config['onlyFirst'] = $this->onlyFirst; $keywords = \array_unique(\iterator_to_array($this->collection)); \sort($keywords); $groups = []; $groupKey = 0; $groupLen = 0; foreach ($keywords as $keyword) { $keywordLen = 4 + \strlen($keyword); $groupLen += $keywordLen; if ($groupLen > 30000) { $groupLen = $keywordLen; ++$groupKey; } $groups[$groupKey][] = $keyword; } foreach ($groups as $keywords) { $regexp = RegexpBuilder::fromList( $keywords, ['caseInsensitive' => !$this->caseSensitive] ); $regexp = '/\\b' . $regexp . '\\b/S'; if (!$this->caseSensitive) $regexp .= 'i'; if (\preg_match('/[^[:ascii:]]/', $regexp)) $regexp .= 'u'; $config['regexps'][] = new Regexp($regexp, \true); } return $config; } }