@param array  $dirs
@param string $match

@return SplFileInfo[]|RegexIterator
498254
public function getFilesOfDirs(array $dirs, $match = '/\.php$/')
    {
        $iterator = new AppendIterator();

        foreach ($dirs as $dir) {
            $iterator->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)));
        }

        return new RegexIterator($iterator, $match);
    }
785366
protected static function replaceBlock(array $matches)
    {
        $matches[3] = self::removeTrailingNewline($matches[3]);

        if (preg_match_all(self::$regex, self::$childSource, $override) && in_array($matches[2], $override[2])) {
            $key      = array_search($matches[2], $override[2]);
            $override = self::removeTrailingNewline($override[3][$key]);

            $l = stripslashes(self::$l);
            $r = stripslashes(self::$r);

            if (self::$lastReplacement) {
                return preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override);
            }

            return $l . 'block ' . $matches[1] . $matches[2] . $matches[1] . $r . preg_replace('/' . self::$l . '\$dwoo\.parent' . self::$r . '/is', $matches[3], $override) . $l . '/block' . $r;
        }

        if (preg_match(self::$regex, $matches[3])) {
            return preg_replace_callback(self::$regex, array(
                'Dwoo\Plugins\Functions\PluginExtends',
                'replaceBlock'
            ), $matches[3]);
        }

        if (self::$lastReplacement) {
            return $matches[3];
        }

        return $matches[0];
    }
850574
public function matching ($pattern, &$matches = [], $flags = 0, $offset = 0, $start = 0, $end = null) {
		if (is_null($end)) {
			$end = $this->_length;
		}
		return static::Match($pattern, static::Substring($this->_string, $start, $end), $matches, $flags, $offset);
	}
1207629
private function tableClb($matches)
    {
        return $this->implementation->reprTable($this->connection, $this->prefix.$matches[1]);
    }
317066
private function getSingleChars($match, $ranges)
    {
        foreach ($ranges as $range) {
            $match = str_replace($range, '', $match);
        }
        $match = preg_replace('/((\\\\)(?:.))/', '', $match);

        return $match;
    }
1144455
protected function parseFiles(array $dirs, $fileMatch, $cacheDir = null)
    {
        $files   = $this->filesystem->getFilesOfDirs($dirs, $fileMatch);
        $results = [];

        $tmpFile  = $cacheDir !== null ? $cacheDir . '/' . $this->getCacheFile() : null;
        $oldCache = [];

        if ($tmpFile !== null && file_exists($tmpFile)) {
            $oldCache = unserialize(file_get_contents($tmpFile));
        }

        foreach ($files as $file) {
            $realPath = $file->getRealPath();
            if (!$realPath) {
                return [];
            }

            $hash = $this->filesystem->getFileHash($realPath);

            if (isset($oldCache[$hash])) {
                $fileResult = $this->fromCache($oldCache[$hash], $file);
                unset($oldCache[$hash]);
            } else {
                $fileResult = $this->parseFile($realPath);
            }

            $results[$hash] = $fileResult;
        }

        if ($tmpFile !== null) {
            $this->filesystem->writeFile(
                $tmpFile,
                serialize($results)
            );
        }

        return $results;
    }
1211982
protected static function p(array $matches)
    {
        $line = $matches[1];
        $trimmed = trim($line);

        if (preg_match('/^<\/?(ul|ol|li|h|p|bl)/', $trimmed)) {
            return "\n$line\n";
        }

        return sprintf("\n<p>%s</p>\n", $trimmed);
    }
80798
def match(dirname, basename)
        # Potential `entries` syscall
        matches = @entries[dirname]

        pattern = @patterns[basename]
        matches = matches.select { |m| m =~ pattern }

        sort_matches(matches, basename).each do |path|
          filename = File.join(dirname, path)

          # Potential `stat` syscall
          stat = @stats[filename]

          # Exclude directories
          if stat && stat.file?
            yield filename
          end
        end
      end
1230234
protected static function h(array $matches)
    {
        $level = strlen($matches[1]);
        return sprintf('<h%d>%s</h%d>', $level, trim($matches[2]), $level);
    }
377213
public function getResources($match = null) {

		if(null !== $match && false === is_string($match)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($match)), E_USER_ERROR);
		}

		$permissions = [];
		$match 		 = null === $match ? '.*?' : $match;

		foreach($this -> permissions as $permission) {

			foreach($permission as $type => $value) {

				if(preg_match(sprintf('#%s#', str_replace('#', '\#', $match)), $type)) {
					$permissions[] = $type;			
				}
			}
		}

		return array_unique($permissions);
	}
645592
protected function _findRecursive($pattern, $sort = false)
    {
        list($dirs, $files) = $this->read($sort);
        $found = array();

        foreach ($files as $file) {
            if (preg_match('/^' . $pattern . '$/i', $file)) {
                $found[] = Folder::addPathElement($this->path, $file);
            }
        }
        $start = $this->path;

        foreach ($dirs as $dir) {
            $this->cd(Folder::addPathElement($start, $dir));
            $found = array_merge($found, $this->findRecursive($pattern, $sort));
        }

        return $found;
    }
390986
public function match(array $matches) {
        $params = explode(' ', $matches[1]);
        $paramsNum = count($params);
        $this->params[] = $params[0];

        if (1 == $paramsNum) {
            return sprintf($this->defaultRegx['char'], '+');
        }
        else if (2 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '+');
        }
        else if (3 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], $params[2] > 0 ? '{' . $params[2] . '}' : '*');
        }
        else if (4 == $paramsNum) {
            return sprintf($this->defaultRegx[$params[1]], '{' . $params[2] . ',' . $params[3] . '}');
        }
    }
421518
function handle_multiline_regexps($matches) {
        $before = $this->_hmr_before;
        $after = $this->_hmr_after;
        if ($this->_hmr_replace) {
            $replace = $this->_hmr_replace;
            $search = array();

            foreach (array_keys($matches) as $k) {
                $search[] = '\\' . $k;
            }

            $before = str_replace($search, $matches, $before);
            $after = str_replace($search, $matches, $after);
            $replace = str_replace($search, $matches, $replace);
        } else {
            $replace = $matches[0];
        }
        return $before
                    . '<|!REG3XP' . $this->_hmr_key .'!>'
                        . str_replace("\n", "|>\n<|!REG3XP" . $this->_hmr_key . '!>', $replace)
                    . '|>'
              . $after;
    }
1250679
public function _parseParams(array $matches)
    {
        $params = array();
        foreach ($matches as $k => $v) {
            if (is_numeric($k)) {
                if ($k === 0) {
                    continue;
                }
                $params[] = $v;
            } else {
                $params[$k] = $v;
            }
        }
        return new Set($params);
    }
604363
protected function getMatchArgs(array $match)
    {
        // Remove the first element, the matching regex
        array_shift($match);

        // Iterate through the arguments and remove any unwanted slashes
        foreach ($match as &$arg) {
            $arg = trim($arg, '/');
        }

        return $match;
    }
1161554
protected function getFoundIdentifiers($match)
    {
        return $this->objectManager
                    ->getClassMetadata($this->objectRepository->getClassName())
                    ->getIdentifierValues($match);
    }
127337
private function generateAttributes(array $matches): Generator
    {
        foreach ($matches as $match) {
            $m = array_filter($match);
            $key = $m[1] ?? $m[3] ?? $m[5] ?? $m[7] ?? $m[8] ?? $m[9];
            $stringMatch = $m[2] ?? $m[4] ?? $m[6] ?? false;
            $value = $stringMatch ? stripcslashes($stringMatch) : true;
            yield strtolower($key) => $value;
        }
    }