processLongArgument() 공개 메소드

Processes a long (--example) command line argument.
public processLongArgument ( string $arg, integer $pos ) : void
$arg string The command line argument.
$pos integer The position of the argument on the command line.
리턴 void
예제 #1
0
 public function processLongArgument($arg, $pos)
 {
     if (substr($arg, 0, 10) === 'namespace=') {
         $this->namespace = substr($arg, 10);
         return;
     }
     parent::processLongArgument($arg, $pos);
 }
예제 #2
0
 /**
  * Processes a long (--example) command line argument.
  *
  * @param string $arg    The command line argument.
  * @param int    $pos    The position of the argument on the command line.
  * @param array  $values An array of values determined from CLI args.
  *
  * @return array The updated CLI values.
  * @see getCommandLineValues()
  */
 public function processLongArgument($arg, $pos, $values)
 {
     if (substr($arg, 0, 6) === 'level=') {
         $showLevel = strtoupper(substr($arg, 6));
         if (defined('SQLI_CodeSniffer_Reports::' . $showLevel)) {
             $values['showLevel'] = constant('SQLI_CodeSniffer_Reports::' . $showLevel);
         }
     } elseif ($arg == 'version') {
         echo 'SQLI_CodeSniffer version @package_version@ (alpha) ';
         echo 'by SQLI (http://www.sqli.com)' . PHP_EOL;
         exit(0);
     } else {
         $values = parent::processLongArgument($arg, $pos, $values);
     }
     return $values;
 }
<?php

/**
 * Pre-commit hook entry point
 *
 * PHP version 5
 *
 * @category  DiffSniffer
 * @package   DiffSniffer
 * @author    Sergei Morozov <*****@*****.**>
 * @copyright 2014 Sergei Morozov
 * @license   http://mit-license.org/ MIT Licence
 * @link      http://github.com/morozov/diff-sniffer-pre-commit
 */
$autoload = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($autoload)) {
    echo 'You must set up the project dependencies, run the following commands:' . PHP_EOL . 'curl -sS https://getcomposer.org/installer | php' . PHP_EOL . 'php composer.phar install' . PHP_EOL;
    exit(2);
}
require $autoload;
$arguments = $_SERVER['argv'];
array_shift($arguments);
if ($arguments && $arguments[0] == '--version') {
    echo 'Diff Sniffer Pre-Commit Hook version 2.3.0.1' . PHP_EOL;
    $cli = new PHP_CodeSniffer_CLI();
    $cli->processLongArgument('version', null, null);
    exit;
}
$runner = new \DiffSniffer\Runner\Staged();
$return_var = $runner->run(getcwd(), $arguments);
exit($return_var);
예제 #4
0
파일: CLI.php 프로젝트: jpchristie/Scisr
 private function parseOtherOpts($params)
 {
     foreach ($params as $key => $value) {
         switch ($key) {
             case "a":
             case "aggressive":
                 $this->scisr->setEditMode(ScisrRunner::MODE_AGGRESSIVE);
                 break;
             case "no-inheritance":
                 $this->withInheritance = false;
                 break;
             case "t":
             case "timid":
                 $this->scisr->setEditMode(ScisrRunner::MODE_TIMID);
                 break;
             case "i":
             case "ignore":
                 // We doctor and pass this value in to let phpcs run a pattern on it
                 $fakekey = 'ignore=' . $value;
                 $cli = new PHP_CodeSniffer_CLI();
                 $result = $cli->processLongArgument($fakekey, null, array());
                 $this->scisr->setIgnorePatterns($result['ignored']);
                 break;
             case "e":
             case "extensions":
                 // We doctor and pass this value in to let phpcs run a pattern on it
                 $fakekey = 'extensions=' . $value;
                 $cli = new PHP_CodeSniffer_CLI();
                 $result = $cli->processLongArgument($fakekey, null, array());
                 $this->scisr->setAllowedFileExtensions($result['extensions']);
                 break;
             case "help":
                 $this->showHelp = true;
                 break;
         }
     }
 }