PHP_CodeSniffer_CLI::getCommandLineValues PHP Method

getCommandLineValues() public method

If the values have not yet been set, the values will be sourced from the command line arguments.
public getCommandLineValues ( ) : array
return array
    public function getCommandLineValues()
    {
        if (empty($this->values) === false) {
            return $this->values;
        }
        $args = $_SERVER['argv'];
        array_shift($args);
        $this->setCommandLineValues($args);
        // Check for content on STDIN.
        $handle = fopen('php://stdin', 'r');
        if (stream_set_blocking($handle, false) === true) {
            $fileContents = '';
            while (($line = fgets($handle)) !== false) {
                $fileContents .= $line;
                usleep(10);
            }
            stream_set_blocking($handle, true);
            fclose($handle);
            if (trim($fileContents) !== '') {
                $this->values['stdin'] = $fileContents;
            }
        }
        return $this->values;
    }

Usage Example

Example #1
0
File: Cli.php Project: memaw/phpcs
 /**
  * Run the coding style check
  *
  * @return int
  */
 public function process()
 {
     $this->setDefaultValues();
     \PHP_CodeSniffer_Reporting::startTiming();
     $phpcs = new \PHP_CodeSniffer_CLI();
     $phpcs->checkRequirements();
     $values = $phpcs->getCommandLineValues();
     foreach ($this->defaultValues as $k => $v) {
         if (empty($values[$k])) {
             $values[$k] = $v;
         }
     }
     return $phpcs->process($values);
 }
All Usage Examples Of PHP_CodeSniffer_CLI::getCommandLineValues