Skip to content

Commit

Permalink
Code Style Fixes - Round 2
Browse files Browse the repository at this point in the history
  • Loading branch information
photodude authored and wilsonge committed May 15, 2017
1 parent 41ad336 commit 0d6ea72
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
*/
public $firstVarException = false;


/**
* Processes the function tokens within the class.
*
Expand Down Expand Up @@ -96,8 +97,8 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($first - 1), null, true);
$foundLines = ($tokens[$first]['line'] - $tokens[$prev]['line'] - 1);

// Exception to the newline requirement on the first member var after class opener.
if($this->firstVarException) {
// Exception to the newline requirement on the first member var after class opener.
if ($this->firstVarException === true) {
if ($foundLines > 0 && $tokens[$prev]['code'] === T_OPEN_CURLY_BRACKET) {
$error = 'Expected 0 blank lines before first member var; %s found';
$data = array($foundLines);
Expand All @@ -108,18 +109,21 @@ protected function processMemberVar(File $phpcsFile, $stackPtr)
if ($tokens[$i]['line'] === $tokens[$prev]['line']) {
continue;
}

if ($tokens[$i]['line'] === $tokens[$first]['line']) {
break;
}

$phpcsFile->fixer->replaceToken($i, '');
}
$phpcsFile->fixer->endChangeset();
}
}
}
if ($foundLines === 1 || ($this->firstVarException && $tokens[$prev]['code'] === T_OPEN_CURLY_BRACKET)) {
return;
}
}

if ($foundLines === 1 || ($this->firstVarException === true && $tokens[$prev]['code'] === T_OPEN_CURLY_BRACKET)) {
return;
}

$error = 'Expected 1 blank line before member var; %s found';
$data = array($foundLines);
Expand Down

0 comments on commit 0d6ea72

Please sign in to comment.