protected static function PHPUnit_Util_Getopt::parseShortOption

1 call to PHPUnit_Util_Getopt::parseShortOption()
PHPUnit_Util_Getopt::getopt in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Getopt.php

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/Getopt.php, line 112

Class

PHPUnit_Util_Getopt
Command-line options parsing class.

Code

protected static function parseShortOption($arg, $short_options, &$opts, &$args) {
  $argLen = strlen($arg);
  for ($i = 0; $i < $argLen; $i++) {
    $opt = $arg[$i];
    $opt_arg = NULL;
    if (($spec = strstr($short_options, $opt)) === FALSE || $arg[$i] == ':') {
      throw new PHPUnit_Framework_Exception("unrecognized option -- {$opt}");
    }
    if (strlen($spec) > 1 && $spec[1] == ':') {
      if (strlen($spec) > 2 && $spec[2] == ':') {
        if ($i + 1 < $argLen) {
          $opts[] = array(
            $opt,
            substr($arg, $i + 1),
          );
          break;
        }
      }
      else {
        if ($i + 1 < $argLen) {
          $opts[] = array(
            $opt,
            substr($arg, $i + 1),
          );
          break;
        }
        else {
          if (list(, $opt_arg) = each($args)) {
          }
          else {
            throw new PHPUnit_Framework_Exception("option requires an argument -- {$opt}");
          }
        }
      }
    }
    $opts[] = array(
      $opt,
      $opt_arg,
    );
  }
}