diff --git a/CodeSniffer.php b/CodeSniffer.php index c0010cbdd3..e95295b1db 100644 --- a/CodeSniffer.php +++ b/CodeSniffer.php @@ -269,6 +269,10 @@ public function __construct( */ public static function autoload($className) { + if (class_exists($className, false) === true) { + return; + } + if (substr($className, 0, 4) === 'PHP_') { $newClassName = substr($className, 4); } else { @@ -1789,11 +1793,12 @@ public function processFile($file, $contents=null) $reportData = $this->reporting->prepareFileReport($phpcsFile); $reportClass->generateFileReport($reportData, $phpcsFile, $cliValues['showSources'], $cliValues['reportWidth']); - if (empty(PHP_CODESNIFFER_EDITOR_PATH)) { + if (empty(PHP_CODESNIFFER_EDITOR_PATH) === true) { echo ' to recheck, [s] to skip or [q] to quit : '; } else { echo ' to recheck, [s] to skip, [o] to open in editor or [q] to quit : '; } + $input = fgets(STDIN); $input = trim($input); @@ -1804,7 +1809,7 @@ public function processFile($file, $contents=null) exit(0); break; case 'o': - if (false == empty(PHP_CODESNIFFER_EDITOR_PATH)) { + if (false === empty(PHP_CODESNIFFER_EDITOR_PATH)) { exec(PHP_CODESNIFFER_EDITOR_PATH.' '.$file); } break; diff --git a/CodeSniffer/CLI.php b/CodeSniffer/CLI.php index d3901b2ed5..e669140d97 100644 --- a/CodeSniffer/CLI.php +++ b/CodeSniffer/CLI.php @@ -707,14 +707,15 @@ public function processLongArgument($arg, $pos) $this->values['warningSeverity'] = (int) substr($arg, 17); } else if (substr($arg, 0, 12) === 'editor-path=') { $value = substr($arg, 12); - if (preg_match('/^[\'\"]/', $value, $matches)) { + if (1 === preg_match('/^[\'\"]/', $value, $matches)) { while (0 === preg_match("/[{$matches[0]}]$/", $value)) { $value .= ' '.$this->_cliArgs[++$pos]; $this->_cliArgs[$pos] = ''; } + $value = substr($value, 1, -1); } - + $this->values['editorPath'] = $value; } else if (substr($arg, 0, 7) === 'ignore=') { // Split the ignore string on commas, unless the comma is escaped