Skip to content

Commit

Permalink
[PMakowski] squizlabs#2.5.1.x-dev: fix T_PAAMAYIM_NEKUDOTAYIM in some…
Browse files Browse the repository at this point in the history
… builds
  • Loading branch information
Piotr Makowski committed Mar 18, 2016
1 parent f521d7f commit c58ea75
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions CodeSniffer.php
Expand Up @@ -135,6 +135,13 @@ class PHP_CodeSniffer
* @var array
*/
private $_tokenListeners = array();

/**
* The editor path / command
*
* @var string|null
*/
protected $editorPath = null;

/**
* An array of rules from the ruleset.xml file.
Expand Down Expand Up @@ -380,21 +387,40 @@ public function setInteractive($interactive)


/**
* Sets the interactive flag.
* Sets the editor path / command
*
* @return string|null
*/
public function getEditorPath()
{
return $this->editorPath;
}//end getEditorPath()


/**
* Sets the editor path / command
*
* @param string $path During interactive session will use this to open invalid files.
*
* @return void
*/
public function setEditorPath($path)
{
if (defined('PHP_CODESNIFFER_EDITOR_PATH') === false) {
define('PHP_CODESNIFFER_EDITOR_PATH', $path);
}

$this->editorPath = $path;
}//end setEditorPath()


/**
* Returns true if the editor path / command was set
*
* @return boolean
*/
public function isEditorPathSet()
{
return false === empty($this->editorPath);
}//end isEditorPathSet()


/**
* Sets an array of file extensions that we will allow checking of.
*
Expand Down Expand Up @@ -1789,10 +1815,10 @@ 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) === true) {
echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
} else {
if ($this->isEditorPathSet()) {
echo '<ENTER> to recheck, [s] to skip, [o] to open in editor or [q] to quit : ';
} else {
echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
}

$input = fgets(STDIN);
Expand All @@ -1805,8 +1831,8 @@ public function processFile($file, $contents=null)
exit(0);
break;
case 'o':
if (false === empty(PHP_CODESNIFFER_EDITOR_PATH)) {
exec(PHP_CODESNIFFER_EDITOR_PATH.' '.$file);
if ($this->isEditorPathSet()) {
exec($this->getEditorPath().' '.$file);
}
break;
default:
Expand Down

0 comments on commit c58ea75

Please sign in to comment.