/** * Processes an unknown command line argument. * * Assumes all unknown arguments are files and folders to check. * * @param string $arg The command line argument. * @param int $pos The position of the argument on the command line. * * @return void */ public function processUnknownArgument($arg, $pos) { $file = PHP_CodeSniffer::realpath($arg); if (file_exists($file) === false) { if ($this->dieOnUnknownArg === false) { return; } echo 'ERROR: The file "' . $arg . '" does not exist.' . PHP_EOL . PHP_EOL; $this->printUsage(); exit(2); } else { $this->values['files'][] = $file; } }
/** * Processes an unknown command line argument. * * Assumes all unknown arguments are files and folders to check. * * @param string $arg The command line argument. * @param int $pos The position of the argument on the command line. * * @return void */ public function processUnknownArgument($arg, $pos) { // We don't know about any additional switches; just files. if ($arg[0] === '-') { if ($this->dieOnUnknownArg === false) { return; } echo 'ERROR: option "' . $arg . '" not known.' . PHP_EOL . PHP_EOL; $this->printUsage(); exit(2); } $file = PHP_CodeSniffer::realpath($arg); if (file_exists($file) === false) { if ($this->dieOnUnknownArg === false) { return; } echo 'ERROR: The file "' . $arg . '" does not exist.' . PHP_EOL . PHP_EOL; $this->printUsage(); exit(2); } else { $this->values['files'][] = $file; } }
/** * Processes an unknown command line argument. * * Assumes all unknown arguments are files and folders to check. * * @param string $arg The command line argument. * @param int $pos The position of the argument on the command line. * * @return void */ public function processUnknownArgument($arg, $pos) { // We don't know about any additional switches; just files. if ($arg[0] === '-') { if ($this->dieOnUnknownArg === false) { return; } echo 'ERROR: option "' . $arg . '" not known.' . PHP_EOL . PHP_EOL; $this->printUsage(); exit(2); } $file = PHP_CodeSniffer::realpath($arg); if (file_exists($file) === false) { // Check if anything was passed via STDIN. $read = array(STDIN); $write = array(); $except = array(); $result = stream_select($read, $write, $except, 0); if ($result === 1) { return; } if ($this->dieOnUnknownArg === false) { return; } echo 'ERROR: The file "' . $arg . '" does not exist.' . PHP_EOL . PHP_EOL; $this->printUsage(); exit(2); } else { $this->values['files'][] = $file; } }