Skip to content

Commit c090358

Browse files
committed
Changelog + sniff property name change for #2515
1 parent 3f31da2 commit c090358

File tree

6 files changed

+16
-9
lines changed

6 files changed

+16
-9
lines changed

package.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
8585
- Squiz.WhiteSpace.FunctionSpacing now applies beforeFirst and afterLast spacing rules to nested functions
8686
-- Previously, these rules only applied to the first and last function in a class, interface, or trait
8787
-- These rules now apply to functions nested in any statement block, including other functions and conditions
88+
- Squiz.WhiteSpace.OperatorSpacing can now enforce a single space before assignment operators
89+
-- Previously, the sniff this spacing as multiple assignment operators are sometimes aligned
90+
-- Now, you can set the ignoreSpacingBeforeAssignments sniff property to FALSE to enable checking
91+
-- Default remains TRUE, so spacing before assignments is not checked by default
92+
-- Thanks to Jakub Chábek for the patch
8893
- Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files
8994
-- Thanks to Juliette Reinders Folmer and Willington Vega for the patch
9095
- Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally

src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ class OperatorSpacingSniff implements Sniff
3434
public $ignoreNewlines = false;
3535

3636
/**
37-
* Allow multiple assignment statements to be aligned (don't check space before assignment operator)
37+
* Don't check spacing for assignment operators.
38+
*
39+
* This allows multiple assignment statements to be aligned.
3840
*
3941
* @var boolean
4042
*/
41-
public $allowMultipleStatementsAlignment = true;
43+
public $ignoreSpacingBeforeAssignments = true;
4244

4345

4446
/**
@@ -152,10 +154,10 @@ public function process(File $phpcsFile, $stackPtr)
152154

153155
$phpcsFile->recordMetric($stackPtr, 'Space before operator', 0);
154156
} else if (isset(Tokens::$assignmentTokens[$tokens[$stackPtr]['code']]) === false
155-
|| $this->allowMultipleStatementsAlignment === false
157+
|| $this->ignoreSpacingBeforeAssignments === false
156158
) {
157-
// Throw an error for assignments only if that behaviour is enabled using the sniff property,
158-
// because other standards allow multiple spaces there to align multiple assignments.
159+
// Throw an error for assignments only if enabled using the sniff property
160+
// because other standards allow multiple spaces to align assignments.
159161
if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
160162
$found = 'newline';
161163
} else {

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,5 @@ if ($line{-1} === ':') {
261261
$line = substr($line, 0, -1);
262262
}
263263

264-
// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
264+
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
265265
$a = 3;

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,5 +255,5 @@ if ($line{-1} === ':') {
255255
$line = substr($line, 0, -1);
256256
}
257257

258-
// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
258+
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
259259
$a = 3;

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ x >>>= y;
9999

100100
var foo = bar.map(baz=> baz.length);
101101

102-
// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
102+
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
103103
a = 3;

src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.js.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,5 @@ x >>>= y;
9393

9494
var foo = bar.map(baz => baz.length);
9595

96-
// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
96+
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
9797
a = 3;

0 commit comments

Comments
 (0)