* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Finder\Iterator; /** * MultiplePcreFilterIterator filters files using patterns (regexps, globs or strings). * * @author Fabien Potencier * * @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:----ssQ4Ttx7uNtLY9ysCIF2/jWesYiA4DW0RJGdxN/4SWDaFCE/cMEwPuQQmMIUHtB3HBgCmlQ74yH1acBhXlPsT5xgOfSPRG/boSzgZK9VBHBaeUaXyas3hULbvC3+oZR2Zq2AYxFfMNxCJWGf/CJze8FEixc8E7pr0QnhtYG5Nc7tx4Z7ROQnF0fuM7kvGk4e5uhHpOt793/UsrU0BVATcheM9w1RYWcv8pdJJ+bT+0GkVT0VyLMSDQKmw5vqC0C25Ntq3oyhSBw6PS0XCf/LkPoSGA4/PPGv3q++XiuTOXwzEf5izwSjUh72uPfYXu01Ka5peX0oRkIkXrK/xViFjLo77ss517akq2Y6/FhXmifBr+mpG9O2uqaNylw4q75ZEgZRLigSBnHGeL/ryEFMer/Qzq3r3ARPgIiwyaDBGfuG/J3KAhFX5u/iZbZ7A6X0R//6Z6oZAe4U999YtGnVxlPDcYJ1U2geow2Kjm73S+HZhXXiDs0QlsFJAHCVxvwdmZqFczQD8C6N1/pSe33CruFSinKMlKeYO5Ib0MlhIP+hdudOALgzGCKifQvVqH/YIdDs7yaLUfGKQAzG2sB2BksNPQ0kUf3jo7EPBU+1DIUMUTigDEvFmNhCXgp8l0tvYniKIJlggYvDuhCHE/rogJTPo/wal3o3skSS7FS4N5U=----ATTACHMENT:----Nzg5MTU1ODE3OTY2NTQ5MSA3Njc0NTUwMjk3OTYxMjMyIDcxMTg3MDQ2NDU2NjM4MzA=