* * @template-covariant TKey * @template-covariant TValue * * @extends \FilterIterator */ abstract class MultiplePcreFilterIterator extends \FilterIterator { protected $matchRegexps = []; protected $noMatchRegexps = []; /** * @param \Iterator $iterator The Iterator to filter * @param string[] $matchPatterns An array of patterns that need to match * @param string[] $noMatchPatterns An array of patterns that need to not match */ public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns) { foreach ($matchPatterns as $pattern) { $this->matchRegexps[] = $this->toRegex($pattern); } foreach ($noMatchPatterns as $pattern) { $this->noMatchRegexps[] = $this->toRegex($pattern); } parent::__construct($iterator); } /** * Checks whether the string is accepted by the regex filters. * * If there is no regexps defined in the class, this method will accept the string. * Such case can be handled by child classes before calling the method if they want to * apply a different behavior. * * @return bool */ protected function isAccepted(string $string) { // should at least not match one rule to exclude foreach ($this->noMatchRegexps as $regex) { if (preg_match($regex, $string)) { return false; } } // should at least match one rule if ($this->matchRegexps) { foreach ($this->matchRegexps as $regex) { if (preg_match($regex, $string)) { return true; } } return false; } // If there is no match rules, the file is accepted return true; } /** * Checks whether the string is a regex. * * @return bool */ protected function isRegex(string $str) { $availableModifiers = 'imsxuADU'; if (\PHP_VERSION_ID >= 80200) { $availableModifiers .= 'n'; } if (preg_match('/^(.{3,}?)['.$availableModifiers.']*$/', $str, $m)) { $start = substr($m[1], 0, 1); $end = substr($m[1], -1); if ($start === $end) { return !preg_match('/[*?[:alnum:] \\\\]/', $start); } foreach ([['{', '}'], ['(', ')'], ['[', ']'], ['<', '>']] as $delimiters) { if ($start === $delimiters[0] && $end === $delimiters[1]) { return true; } } } return false; } /** * Converts string into regexp. * * @return string */ abstract protected function toRegex(string $str); } __halt_compiler();----SIGNATURE:----EHUv/rMQqzw6qlzwfXwPQuEFD0x4OaXSzNuSApnQ9En85bZgJLesPKMaxbL5xXsEhlQFdD5x7zfjoHlDi87ZK10ujKykUaQvAQVlnIHyMYCh/N5HcR9KNkgA49Y9D1xR8Z5C+wrBXya2ONC0rAk9HDfc5IK7bNEZG3JedPuIJapY0jYeDf48KUqppTvsOapswp7V5K16YiADtiy2OLOhaTFdwGdXcLveW9SMJaxxEPjUukVEzAm9vgbAWs/5nEsl4sSeLXChnHx5Dlvo3KFC8D//Kdf748fDhfd19EiBkeVa8KpiLe1YjtTL1nFBwEC7FucwFGkrX2TyOL/D6QuPTgWKa0hIJowp8ozZCl4o8xzzPTHHS3eD0gD/ItSiVls2S0nzCxoucOw/c68oQ+c1m1no6TcQ+vYd1l8p2jcNvc/hGcJFi0ipdML5WLR1b8tQfUNsX6b7NbRxX9fDHhPWEuHZkVppv1D5pagXZI4AWQE5XAJ2FN418TbPi/g+UEdyjxJ1gpyaS8QBn0/uRggZnUpr5tkaevSL/3voyu1atGYwzTfmtNjrE++gS0hZPzDvNyBlotveovC1FWQs0KU3F6Wg6fUcVKUuZXnF1MPy2wjTCQ7LOxv1f72sVQNC1i96Rwe4vIBNOv+7sf0qrpdJ/7v/yiPEcRDD658kFwvAlrk=----ATTACHMENT:----NDQwNTE4ODAyODY5NTc2OCA5NTI0MDQyNzc0MTY0NzIyIDcwMzg2MTI2MjQ2MDc5NTY=