src/Glob.php
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);
    }
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);
    }
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 ) ; }
Find the end of the sub-pattern in a brace expression.

@param  string  $pattern
@param  int $begin
@param  int $flags
@return int|null
Find the end of the sub - pattern in a brace expression .