Skip to content

Commit

Permalink
Remove trailing spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfnl committed Aug 3, 2016
1 parent 50eee20 commit 3215a35
Show file tree
Hide file tree
Showing 17 changed files with 59 additions and 60 deletions.
14 changes: 7 additions & 7 deletions Sniffs/PHP/ConstantArraysUsingDefineSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,36 @@ public function register()
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();

$ignore = array(
T_DOUBLE_COLON,
T_OBJECT_OPERATOR,
T_FUNCTION,
T_CONST,
);

$prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
if (in_array($tokens[$prevToken]['code'], $ignore) === true) {
// Not a call to a PHP function.
return;
}

$function = strtolower($tokens[$stackPtr]['content']);

if ($function === 'define') {
$openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, null, null, true);
if ($openParenthesis === false) {
return;
}

$comma = $phpcsFile->findNext(T_COMMA, $openParenthesis, $tokens[$openParenthesis]['parenthesis_closer']);

if ($comma === false) {
return;
}

$array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $comma, $tokens[$openParenthesis]['parenthesis_closer']);

if ($array !== false) {
if ($this->supportsAbove('7.0')) {
return;
Expand Down
12 changes: 6 additions & 6 deletions Sniffs/PHP/DeprecatedFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
* @var bool
*/
protected $patternMatch = false;

/**
* A list of forbidden functions with their alternatives.
*
Expand Down Expand Up @@ -622,18 +622,18 @@ public function register()
// Everyone has had a chance to figure out what forbidden functions
// they want to check for, so now we can cache out the list.
$this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);

if ($this->patternMatch === true) {
foreach ($this->forbiddenFunctionNames as $i => $name) {
$this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
}
}

return array(T_STRING);

}//end register()


/**
* Processes this test, when one of its tokens is encountered.
*
Expand Down
2 changes: 1 addition & 1 deletion Sniffs/PHP/DeprecatedIniDirectivesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public function register()
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();

$isError = false;

$ignore = array(
Expand Down
4 changes: 2 additions & 2 deletions Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
$oldConstructorPos = false;
while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
$funcNamePos = $phpcsFile->findNext(T_STRING, $nextFunc);

if ($tokens[$funcNamePos]['content'] === '__construct') {
$newConstructorFound = true;
}
Expand All @@ -57,7 +57,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
}
}
}

if ($newConstructorFound === false && $oldConstructorFound === true) {
$phpcsFile->addError('Deprecated PHP4 style constructor are not supported since PHP7', $oldConstructorPos);
}
Expand Down
4 changes: 2 additions & 2 deletions Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)

$open = $phpcsFile->findNext(T_OPEN_PARENTHESIS, $stackPtr, null, false);
$close = $phpcsFile->findNext(T_CLOSE_PARENTHESIS, $stackPtr, null, false);

$error = true;
for ($cnt = $open + 1; $cnt < $close; $cnt++) {
if ($tokens[$cnt]['type'] != 'T_WHITESPACE' && $tokens[$cnt]['type'] != 'T_COMMA') {
$error = false;
}
}

if ($open !== false && $close !== false) {
if (
$close - $open == 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
$paramNames[] = strtolower($param['name']);
}

if (count($paramNames) != count(array_unique($paramNames))) {
$phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
}
Expand Down
4 changes: 2 additions & 2 deletions Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshift.
*
* Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
* Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0
*
* @category PHP
* @package PHPCompatibility
Expand Down Expand Up @@ -45,7 +45,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0')) {
$tokens = $phpcsFile->getTokens();

$nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr, null, false, null, true);
if ($tokens[$nextNumber - 1]['code'] == T_MINUS) {
$error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
Expand Down
4 changes: 2 additions & 2 deletions Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
if ($this->supportsAbove('7.0')) {
$tokens = $phpcsFile->getTokens();

$defaultToken = $stackPtr;
$defaultCount = 0;
if (isset($tokens[$stackPtr]['scope_closer'])) {
Expand All @@ -58,7 +58,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$defaultCount++;
}
}

if ($defaultCount > 1) {
$phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
}
Expand Down
2 changes: 1 addition & 1 deletion Sniffs/PHP/NewAnonymousClassesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if ($whitespace === false || $class === false) {
return;
}

if ($this->supportsAbove('7.0')) {
return;
} else {
Expand Down
1 change: 0 additions & 1 deletion Sniffs/PHP/NewClassesSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}



}//end process()


Expand Down
4 changes: 2 additions & 2 deletions Sniffs/PHP/NewFunctionArrayDereferencingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function register()
{
return array(T_STRING);
}//end register()

/**
* Processes this test, when one of its tokens is encountered.
*
Expand All @@ -51,7 +51,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
// Not a call to a PHP function.
return;
}

if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
$closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];
if ($tokens[$closeParenthesis + 1]['type'] == 'T_OPEN_SQUARE_BRACKET') {
Expand Down
16 changes: 8 additions & 8 deletions Sniffs/PHP/NewFunctionParametersSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
* @var bool
*/
protected $patternMatch = false;

/**
* A list of new functions, not present in older versions.
*
Expand Down Expand Up @@ -66,7 +66,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib


/**
*
*
* @var array
*/
private $newFunctionParametersNames;
Expand All @@ -82,16 +82,16 @@ public function register()
// Everyone has had a chance to figure out what forbidden functions
// they want to check for, so now we can cache out the list.
$this->newFunctionParametersNames = array_keys($this->newFunctionParameters);

if ($this->patternMatch === true) {
foreach ($this->newFunctionParametersNames as $i => $name) {
$this->newFunctionParametersNames[$i] = '/'.$name.'/i';
}
}

return array(T_STRING);
}//end register()

/**
* Processes this test, when one of its tokens is encountered.
*
Expand Down Expand Up @@ -123,7 +123,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if (in_array($function, $this->newFunctionParametersNames) === false) {
return;
}

if (isset($tokens[$stackPtr + 1]) && $tokens[$stackPtr + 1]['type'] == 'T_OPEN_PARENTHESIS') {
$closeParenthesis = $tokens[$stackPtr + 1]['parenthesis_closer'];

Expand All @@ -138,7 +138,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}
$cnt++;
}

}
}//end process()

Expand Down Expand Up @@ -167,7 +167,7 @@ protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation
}
}
}

if (strlen($error) > 0) {
$error = 'The function ' . $function . ' does not have a parameter ' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . ' ' . $error;

Expand Down
12 changes: 6 additions & 6 deletions Sniffs/PHP/NewFunctionsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
* @var bool
*/
protected $patternMatch = false;

/**
* A list of new functions, not present in older versions.
*
Expand Down Expand Up @@ -1180,7 +1180,7 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
* @var array
*/
private $forbiddenFunctionNames;


/**
* Returns an array of tokens this test wants to listen for.
Expand All @@ -1192,17 +1192,17 @@ public function register()
// Everyone has had a chance to figure out what forbidden functions
// they want to check for, so now we can cache out the list.
$this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);

if ($this->patternMatch === true) {
foreach ($this->forbiddenFunctionNames as $i => $name) {
$this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
}
}

return array(T_STRING);

}//end register()

/**
* Processes this test, when one of its tokens is encountered.
*
Expand Down
8 changes: 4 additions & 4 deletions Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff
*
* Discourages use of superglobals as parameters for functions.
*
*
* PHP version 5.4
*
* @category PHP
Expand Down Expand Up @@ -39,7 +39,7 @@ public function register() {

/**
* Processes the test.
*
*
* @param PHP_CodeSniffer_file $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
*
Expand All @@ -65,7 +65,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
$phpcsFile->addError("Parameter shadowing super global ($variable) causes fatal error since PHP 5.4", $i);
}
}

}
}
}
}

0 comments on commit 3215a35

Please sign in to comment.