Skip to content

Commit

Permalink
Generic/FunctionCallArgumentSpacing: remove assignment operator spaci…
Browse files Browse the repository at this point in the history
…ng checks

As discussed in 2387, there are dedicated sniffs for checking the spacing around assignment operators:
* `PSR12.Operators.OperatorSpacing`
* `Squiz.WhiteSpace.OperatorSpacing`

Both of these are more comprehensive and more appropriate to use than the limited assignment operator spacing check in this sniff.

Removing the assignment operator spacing checks from this sniff, lowers the risk of fixer conflicts regarding operator spacing and gets rid of duplicate notices in the `PSR12` and `Squiz` standard and inappropriate notices for the `PEAR`, `PSR2` and `Zend` standard.

Includes adjusted unit tests.
  • Loading branch information
jrfnl committed Feb 5, 2019
1 parent 49a3e26 commit feeda47
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public function process(File $phpcsFile, $stackPtr)

$find = [
T_COMMA,
T_VARIABLE,
T_CLOSURE,
T_ANON_CLASS,
T_OPEN_SHORT_ARRAY,
Expand Down Expand Up @@ -157,28 +156,6 @@ public function process(File $phpcsFile, $stackPtr)
}
}
}//end if
} else {
// Token is a variable.
$nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextSeparator + 1), $closeBracket, true);
if ($nextToken !== false) {
if ($tokens[$nextToken]['code'] === T_EQUAL) {
if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) {
$error = 'Expected 1 space before = sign of default value';
$fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeEquals');
if ($fix === true) {
$phpcsFile->fixer->addContentBefore($nextToken, ' ');
}
}

if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) {
$error = 'Expected 1 space after = sign of default value';
$fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceAfterEquals');
if ($fix === true) {
$phpcsFile->fixer->addContent($nextToken, ' ');
}
}
}
}
}//end if
}//end while

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ $result = myFunction($arg1, $arg2);
$result = myFunction($arg1, $arg2, $arg3, $arg4, $arg5);
$result = myFunction($arg1, $arg2, $arg3, $arg4, $arg5);
$result = myFunction($arg1, $arg2 = array());
$result = myFunction($arg1, $arg2 = array());
$result = myFunction($arg1, $arg2 = array());
$result = myFunction($arg1, $arg2 = array());
$result = myFunction($arg1, $arg2 =array());
$result = myFunction($arg1, $arg2= array());
$result = myFunction($arg1, $arg2=array());

$result = myFunction($arg1,
$arg2 = array(),
Expand Down Expand Up @@ -147,5 +147,5 @@ $foobar = functionCallAnonClassParam(
$foo = array(1,2,3);
}
},
$args = array(),
$args=array(),
);
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function getErrorList()
6 => 1,
7 => 2,
8 => 1,
11 => 2,
12 => 2,
13 => 3,
11 => 1,
12 => 1,
13 => 1,
42 => 3,
43 => 3,
45 => 1,
Expand All @@ -52,7 +52,6 @@ public function getErrorList()
132 => 2,
133 => 2,
134 => 1,
150 => 2,
];

}//end getErrorList()
Expand Down

0 comments on commit feeda47

Please sign in to comment.