public static function PHPUnit_Util_Getopt::getopt

1 call to PHPUnit_Util_Getopt::getopt()
PHPUnit_TextUI_Command::handleArguments in drupal/core/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php
Handles the command-line arguments.

File

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

Class

PHPUnit_Util_Getopt
Command-line options parsing class.

Code

public static function getopt(array $args, $short_options, $long_options = NULL) {
  if (empty($args)) {
    return array(
      array(),
      array(),
    );
  }
  $opts = array();
  $non_opts = array();
  if ($long_options) {
    sort($long_options);
  }
  if (isset($args[0][0]) && $args[0][0] != '-') {
    array_shift($args);
  }
  reset($args);
  array_map('trim', $args);
  while (list($i, $arg) = each($args)) {
    if ($arg == '') {
      continue;
    }
    if ($arg == '--') {
      $non_opts = array_merge($non_opts, array_slice($args, $i + 1));
      break;
    }
    if ($arg[0] != '-' || strlen($arg) > 1 && $arg[1] == '-' && !$long_options) {
      $non_opts = array_merge($non_opts, array_slice($args, $i));
      break;
    }
    elseif (strlen($arg) > 1 && $arg[1] == '-') {
      self::parseLongOption(substr($arg, 2), $long_options, $opts, $args);
    }
    else {
      self::parseShortOption(substr($arg, 1), $short_options, $opts, $args);
    }
  }
  return array(
    $opts,
    $non_opts,
  );
}