You are here

protected static function Glob::nextBraceSub in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-stdlib/src/Glob.php \Zend\Stdlib\Glob::nextBraceSub()

Find the end of the sub-pattern in a brace expression.

Parameters

string $pattern:

int $begin:

int $flags:

Return value

int|null

1 call to Glob::nextBraceSub()
Glob::fallbackGlob in vendor/zendframework/zend-stdlib/src/Glob.php
Expand braces manually, then use the system glob.

File

vendor/zendframework/zend-stdlib/src/Glob.php, line 178

Class

Glob
Wrapper for glob with fallback if GLOB_BRACE is not available.

Namespace

Zend\Stdlib

Code

protected static function nextBraceSub($pattern, $begin, $flags) {
  $length = strlen($pattern);
  $depth = 0;
  $current = $begin;
  while ($current < $length) {
    if (!$flags & self::GLOB_NOESCAPE && $pattern[$current] === '\\') {
      if (++$current === $length) {
        break;
      }
      $current++;
    }
    else {
      if ($pattern[$current] === '}' && $depth-- === 0 || $pattern[$current] === ',' && $depth === 0) {
        break;
      }
      elseif ($pattern[$current++] === '{') {
        $depth++;
      }
    }
  }
  return $current < $length ? $current : null;
}