Skip to content

Commit

Permalink
Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positi…
Browse files Browse the repository at this point in the history
…ve when comparison inside closure
  • Loading branch information
gsherwood committed Nov 17, 2020
1 parent 8421eeb commit 6f2a22d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
-- Thanks to Michael S for the patch
- Fixed bug #2913 : Generic.WhiteSpace.ScopeIndent false positive when opening and closing tag on same line inside conditional
- Fixed bug #3157 : PSR2.ControlStructures.SwitchDeclaration.BreakIndent false positive when case keyword is not indented
- Fixed bug #3165 : Squiz.PHP.DisallowComparisonAssignment false positive when comparison inside closure
</notes>
<contents>
<dir name="/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ public function process(File $phpcsFile, $stackPtr)
];

$next = $phpcsFile->findNext($ignore, ($stackPtr + 1), null, true);
if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
&& $tokens[($next - 1)]['code'] === T_STRING
if ($tokens[$next]['code'] === T_CLOSURE
|| ($tokens[$next]['code'] === T_OPEN_PARENTHESIS
&& $tokens[($next - 1)]['code'] === T_STRING)
) {
// Code will look like: $var = myFunction(
// and will be ignored.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ $a = [

$var = $foo->something(!$var);
$var = $foo?->something(!$var);

$callback = function ($value) {
if ($value > 10) {
return false;
}
};

0 comments on commit 6f2a22d

Please sign in to comment.