PHP_CodeSniffer_CLI::setCommandLineValues PHP Method

setCommandLineValues() public method

Set the command line values.
public setCommandLineValues ( array $args ) : void
$args array An array of command line arguments to process.
return void
    public function setCommandLineValues($args)
    {
        if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
            $this->values = array('stdin' => null, 'quiet' => true);
        } else {
            if (empty($this->values) === true) {
                $this->values = $this->getDefaults();
            }
        }
        $this->_cliArgs = $args;
        $numArgs = count($args);
        for ($i = 0; $i < $numArgs; $i++) {
            $arg = $this->_cliArgs[$i];
            if ($arg === '') {
                continue;
            }
            if ($arg[0] === '-') {
                if ($arg === '-' || $arg === '--') {
                    // Empty argument, ignore it.
                    continue;
                }
                if ($arg[1] === '-') {
                    $this->processLongArgument(substr($arg, 2), $i);
                } else {
                    $switches = str_split($arg);
                    foreach ($switches as $switch) {
                        if ($switch === '-') {
                            continue;
                        }
                        $this->processShortArgument($switch, $i);
                    }
                }
            } else {
                $this->processUnknownArgument($arg, $i);
            }
            //end if
        }
        //end for
    }

Usage Example

 public function setCommandLineValues($args)
 {
     parent::setCommandLineValues($args);
     if (!empty($this->values['files'])) {
         return;
     }
     $files = $this->getConfig('files', []);
     foreach (call_user_func($this->finderByConfig, $files) as $file) {
         $this->processUnknownArgument($file->getPathname(), -1);
     }
 }
All Usage Examples Of PHP_CodeSniffer_CLI::setCommandLineValues