You are here

protected static function PHPUnit_Util_Getopt::parseShortOption in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/Getopt.php \PHPUnit_Util_Getopt::parseShortOption()
1 call to PHPUnit_Util_Getopt::parseShortOption()
PHPUnit_Util_Getopt::getopt in vendor/phpunit/phpunit/src/Util/Getopt.php

File

vendor/phpunit/phpunit/src/Util/Getopt.php, line 72

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;
        }
        elseif (list(, $opt_arg) = each($args)) {
        }
        else {
          throw new PHPUnit_Framework_Exception("option requires an argument -- {$opt}");
        }
      }
    }
    $opts[] = array(
      $opt,
      $opt_arg,
    );
  }
}