Skip to content

Commit

Permalink
Generic/ScopeIndent: add tests for issues 110 and 437
Browse files Browse the repository at this point in the history
Both the mentioned issues are fixed by the improvements to the `File::findStartOfStatement()` method in this same PR.

Fixes 110
Fixes 437
Fixes squizlabs/PHP_CodeSniffer 3875
  • Loading branch information
jrfnl committed May 19, 2024
1 parent 2c95a20 commit f2ac92f
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 4 deletions.
35 changes: 35 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,41 @@ foo(function ($foo) {
];
});

// Issue #110.
echo match (1) {
0 => match (2) {
2 => match (3) {
3 => 3,
default => -1,
},
},
1 => match (2) {
1 => match (3) {
3 => 3,
default => -1,
},
2 => match (3) {
3 => 3,
default => -1,
},
},
};

// Issue #437.
match (true) {
default => [
'unrelated' => '',
'example' => array_filter(
array_map(
function () {
return null;
},
[]
)
)
]
};

/* 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 @@ -1579,6 +1579,41 @@ foo(function ($foo) {
];
});

// Issue #110.
echo match (1) {
0 => match (2) {
2 => match (3) {
3 => 3,
default => -1,
},
},
1 => match (2) {
1 => match (3) {
3 => 3,
default => -1,
},
2 => match (3) {
3 => 3,
default => -1,
},
},
};

// Issue #437.
match (true) {
default => [
'unrelated' => '',
'example' => array_filter(
array_map(
function () {
return null;
},
[]
)
)
]
};

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

Expand Down
35 changes: 35 additions & 0 deletions src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,41 @@ foo(function ($foo) {
];
});

// Issue #110.
echo match (1) {
0 => match (2) {
2 => match (3) {
3 => 3,
default => -1,
},
},
1 => match (2) {
1 => match (3) {
3 => 3,
default => -1,
},
2 => match (3) {
3 => 3,
default => -1,
},
},
};

// Issue #437.
match (true) {
default => [
'unrelated' => '',
'example' => array_filter(
array_map(
function () {
return null;
},
[]
)
)
]
};

/* 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 @@ -1579,6 +1579,41 @@ foo(function ($foo) {
];
});

// Issue #110.
echo match (1) {
0 => match (2) {
2 => match (3) {
3 => 3,
default => -1,
},
},
1 => match (2) {
1 => match (3) {
3 => 3,
default => -1,
},
2 => match (3) {
3 => 3,
default => -1,
},
},
};

// Issue #437.
match (true) {
default => [
'unrelated' => '',
'example' => array_filter(
array_map(
function () {
return null;
},
[]
)
)
]
};

/* 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 @@ -192,10 +192,10 @@ public function getErrorList($testFile='')
1527 => 1,
1529 => 1,
1530 => 1,
1590 => 1,
1591 => 1,
1592 => 1,
1593 => 1,
1625 => 1,
1626 => 1,
1627 => 1,
1628 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit f2ac92f

Please sign in to comment.