Skip to content

Commit

Permalink
Resolved conflict between Generic.WhiteSpace.ScopeIndent and PSR2.Met…
Browse files Browse the repository at this point in the history
…hods.FunctionCallSignature in a match block (ref #3255)
  • Loading branch information
gsherwood committed Mar 5, 2021
1 parent 7af643f commit 76b5801
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,11 @@ public function process(File $phpcsFile, $stackPtr)
&& isset($tokens[$checkToken]['scope_opener']) === true
) {
$exact = true;
if ($disableExactEnd > $checkToken) {
if ($tokens[$checkToken]['conditions'] === $tokens[$disableExactEnd]['conditions']) {
$exact = false;
}
}

$lastOpener = null;
if (empty($openScopes) === false) {
Expand Down
30 changes: 30 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,36 @@ $value = match (
$value,
};

function toString(): string
{
return sprintf(
'%s',
match ($type) {
'foo' => 'bar',
},
);
}

$list = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
},
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
$list2 = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
}
];
}
}
];

/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,36 @@ $value = match (
$value,
};

function toString(): string
{
return sprintf(
'%s',
match ($type) {
'foo' => 'bar',
},
);
}

$list = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
},
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
$list2 = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
}
];
}
}
];

/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
?>

Expand Down
30 changes: 30 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,36 @@ $value = match (
$value,
};

function toString(): string
{
return sprintf(
'%s',
match ($type) {
'foo' => 'bar',
},
);
}

$list = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
},
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
$list2 = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
}
];
}
}
];

/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
?>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,36 @@ $value = match (
$value,
};

function toString(): string
{
return sprintf(
'%s',
match ($type) {
'foo' => 'bar',
},
);
}

$list = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
},
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
$list2 = [
'fn' => function ($a) {
if ($a === true) {
echo 'hi';
}
}
];
}
}
];

/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
?>

Expand Down
13 changes: 9 additions & 4 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,15 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
1489 => 1,
1500 => 1,
1503 => 1,
1514 => 1,
1515 => 1,
1516 => 1,
1517 => 1,
1518 => 1,
1520 => 1,
1527 => 1,
1529 => 1,
1530 => 1,
1544 => 1,
1545 => 1,
1546 => 1,
1547 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit 76b5801

Please sign in to comment.