Skip to content

Commit feeda47

Browse files
committed
Generic/FunctionCallArgumentSpacing: remove assignment operator spacing 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.
1 parent 49a3e26 commit feeda47

File tree

3 files changed

+7
-31
lines changed

3 files changed

+7
-31
lines changed

src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public function process(File $phpcsFile, $stackPtr)
8787

8888
$find = [
8989
T_COMMA,
90-
T_VARIABLE,
9190
T_CLOSURE,
9291
T_ANON_CLASS,
9392
T_OPEN_SHORT_ARRAY,
@@ -157,28 +156,6 @@ public function process(File $phpcsFile, $stackPtr)
157156
}
158157
}
159158
}//end if
160-
} else {
161-
// Token is a variable.
162-
$nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($nextSeparator + 1), $closeBracket, true);
163-
if ($nextToken !== false) {
164-
if ($tokens[$nextToken]['code'] === T_EQUAL) {
165-
if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) {
166-
$error = 'Expected 1 space before = sign of default value';
167-
$fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeEquals');
168-
if ($fix === true) {
169-
$phpcsFile->fixer->addContentBefore($nextToken, ' ');
170-
}
171-
}
172-
173-
if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) {
174-
$error = 'Expected 1 space after = sign of default value';
175-
$fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceAfterEquals');
176-
if ($fix === true) {
177-
$phpcsFile->fixer->addContent($nextToken, ' ');
178-
}
179-
}
180-
}
181-
}
182159
}//end if
183160
}//end while
184161

src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ $result = myFunction($arg1, $arg2);
88
$result = myFunction($arg1, $arg2, $arg3, $arg4, $arg5);
99
$result = myFunction($arg1, $arg2, $arg3, $arg4, $arg5);
1010
$result = myFunction($arg1, $arg2 = array());
11-
$result = myFunction($arg1, $arg2 = array());
12-
$result = myFunction($arg1, $arg2 = array());
13-
$result = myFunction($arg1, $arg2 = array());
11+
$result = myFunction($arg1, $arg2 =array());
12+
$result = myFunction($arg1, $arg2= array());
13+
$result = myFunction($arg1, $arg2=array());
1414

1515
$result = myFunction($arg1,
1616
$arg2 = array(),
@@ -147,5 +147,5 @@ $foobar = functionCallAnonClassParam(
147147
$foo = array(1,2,3);
148148
}
149149
},
150-
$args = array(),
150+
$args=array(),
151151
);

src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ public function getErrorList()
3030
6 => 1,
3131
7 => 2,
3232
8 => 1,
33-
11 => 2,
34-
12 => 2,
35-
13 => 3,
33+
11 => 1,
34+
12 => 1,
35+
13 => 1,
3636
42 => 3,
3737
43 => 3,
3838
45 => 1,
@@ -52,7 +52,6 @@ public function getErrorList()
5252
132 => 2,
5353
133 => 2,
5454
134 => 1,
55-
150 => 2,
5655
];
5756

5857
}//end getErrorList()

0 commit comments

Comments
 (0)