private static function doGlobForExpandedPath($filename, $options) {
    $openpath = static::getDirNameForPath($filename);
    $dirname = pathinfo($filename, PATHINFO_DIRNAME);
    $basename = static::getBaseNameForPath($filename);

    $results = [];
    $handle = @opendir($openpath);

    if ($handle === false) {
      return false;
    }
    while (($name = readdir($handle)) !== false) {
      if (static::isFileNamePatternMatch($name, $basename, $options)) {
        if (strpos($filename, DIRECTORY_SEPARATOR) !== false) {
          $name = $dirname . DIRECTORY_SEPARATOR . $name;
        }
        $results[] = $name;
      }
    }
    closedir($handle);

    if ($options & (GLOB_MARK | GLOB_ONLYDIR)) {
      $results = static::doDirectoryOptions($dirname, $results, $options);
    }

    return $results;
  }
private static function doGlobForExpandedPath($filename, $options) {
    $openpath = static::getDirNameForPath($filename);
    $dirname = pathinfo($filename, PATHINFO_DIRNAME);
    $basename = static::getBaseNameForPath($filename);

    $results = [];
    $handle = @opendir($openpath);

    if ($handle === false) {
      return false;
    }
    while (($name = readdir($handle)) !== false) {
      if (static::isFileNamePatternMatch($name, $basename, $options)) {
        if (strpos($filename, DIRECTORY_SEPARATOR) !== false) {
          $name = $dirname . DIRECTORY_SEPARATOR . $name;
        }
        $results[] = $name;
      }
    }
    closedir($handle);

    if ($options & (GLOB_MARK | GLOB_ONLYDIR)) {
      $results = static::doDirectoryOptions($dirname, $results, $options);
    }

    return $results;
  }
private static function doGlobForExpandedPath ( $ filename , $ options ) { $ openpath = static :: getDirNameForPath ( $ filename ) ; $ dirname = pathinfo ( $ filename , PATHINFO_DIRNAME ) ; $ basename = static :: getBaseNameForPath ( $ filename ) ; $ results = [ ] ; $ handle = @ opendir ( $ openpath ) ; if ( $ handle === false ) { return false ; } while ( ( $ name = readdir ( $ handle ) ) !== false ) { if ( static :: isFileNamePatternMatch ( $ name , $ basename , $ options ) ) { if ( strpos ( $ filename , DIRECTORY_SEPARATOR ) !== false ) { $ name = $ dirname . DIRECTORY_SEPARATOR . $ name ; } $ results [ ] = $ name ; } } closedir ( $ handle ) ; if ( $ options & ( GLOB_MARK | GLOB_ONLYDIR ) ) { $ results = static :: doDirectoryOptions ( $ dirname , $ results , $ options ) ; } return $ results ; }
Glob a given path.

At this point any braces and path wildcards have been expaneded.
@param string $path The path to glob, can contain wildcards.
@param int $options Valid Glob flags.
@return Returns an array containing the matched files/directories, an
empty array if no file matched or FALSE on error.
Glob a given path .