Skip to content

Commit

Permalink
Handle parenthesis after scope condition closer
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentLanglet committed Feb 22, 2020
1 parent db617f1 commit 9b53412
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ public function process(File $phpcsFile, $stackPtr)
}

$preOpener = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
if ($preOpener !== false && isset($this->ignoreTokens[$tokens[$preOpener]['code']]) === true) {
if ($preOpener !== false
&& isset($this->ignoreTokens[$tokens[$preOpener]['code']]) === true
&& isset($tokens[$preOpener]['scope_condition']) === false
) {
// Function or language construct call.
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,7 @@ $a = (
null !== $extra
);
// phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines false

if (true) {} ( 1+2) === 3 ? $a = 1 : $a = 2;
class A {} ( 1+2) === 3 ? $a = 1 : $a = 2;
function foo() {} ( 1+2) === 3 ? $a = 1 : $a = 2;
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,7 @@ $a = (
null !== $extra
);
// phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines false

if (true) {} (1+2) === 3 ? $a = 1 : $a = 2;
class A {} (1+2) === 3 ? $a = 1 : $a = 2;
function foo() {} (1+2) === 3 ? $a = 1 : $a = 2;
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public function getErrorList()
141 => 1,
144 => 1,
146 => 1,
163 => 1,
164 => 1,
165 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 9b53412

Please sign in to comment.