Skip to content

Commit

Permalink
Changelog + sniff property name change for #2515
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Aug 8, 2019
1 parent 3f31da2 commit c090358
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
5 changes: 5 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Squiz.WhiteSpace.FunctionSpacing now applies beforeFirst and afterLast spacing rules to nested functions
-- Previously, these rules only applied to the first and last function in a class, interface, or trait
-- These rules now apply to functions nested in any statement block, including other functions and conditions
- Squiz.WhiteSpace.OperatorSpacing can now enforce a single space before assignment operators
-- Previously, the sniff this spacing as multiple assignment operators are sometimes aligned
-- Now, you can set the ignoreSpacingBeforeAssignments sniff property to FALSE to enable checking
-- Default remains TRUE, so spacing before assignments is not checked by default
-- Thanks to Jakub Chábek for the patch
- Fixed bug #2391 : Sniff-specific ignore rules inside rulesets are filtering out too many files
-- Thanks to Juliette Reinders Folmer and Willington Vega for the patch
- Fixed bug #2478 : FunctionCommentThrowTag.WrongNumber when exception is thrown once but built conditionally
Expand Down
12 changes: 7 additions & 5 deletions src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ class OperatorSpacingSniff implements Sniff
public $ignoreNewlines = false;

/**
* Allow multiple assignment statements to be aligned (don't check space before assignment operator)
* Don't check spacing for assignment operators.
*
* This allows multiple assignment statements to be aligned.
*
* @var boolean
*/
public $allowMultipleStatementsAlignment = true;
public $ignoreSpacingBeforeAssignments = true;


/**
Expand Down Expand Up @@ -152,10 +154,10 @@ public function process(File $phpcsFile, $stackPtr)

$phpcsFile->recordMetric($stackPtr, 'Space before operator', 0);
} else if (isset(Tokens::$assignmentTokens[$tokens[$stackPtr]['code']]) === false
|| $this->allowMultipleStatementsAlignment === false
|| $this->ignoreSpacingBeforeAssignments === false
) {
// Throw an error for assignments only if that behaviour is enabled using the sniff property,
// because other standards allow multiple spaces there to align multiple assignments.
// Throw an error for assignments only if enabled using the sniff property
// because other standards allow multiple spaces to align assignments.
if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
$found = 'newline';
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,5 @@ if ($line{-1} === ':') {
$line = substr($line, 0, -1);
}

// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
$a = 3;
Original file line number Diff line number Diff line change
Expand Up @@ -255,5 +255,5 @@ if ($line{-1} === ':') {
$line = substr($line, 0, -1);
}

// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
$a = 3;
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ x >>>= y;

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

// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
a = 3;
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ x >>>= y;

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

// phpcs:set Squiz.WhiteSpace.OperatorSpacing allowMultipleStatementsAlignment false
// phpcs:set Squiz.WhiteSpace.OperatorSpacing ignoreSpacingBeforeAssignments false
a = 3;

0 comments on commit c090358

Please sign in to comment.