Skip to content

Commit 28c376e

Browse files
committed
Generic/ScopeIndent: add tests for issues 110 and 437
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
1 parent d3abcd6 commit 28c376e

File tree

5 files changed

+144
-4
lines changed

5 files changed

+144
-4
lines changed

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,41 @@ foo(function ($foo) {
15791579
];
15801580
});
15811581

1582+
// Issue #110.
1583+
echo match (1) {
1584+
0 => match (2) {
1585+
2 => match (3) {
1586+
3 => 3,
1587+
default => -1,
1588+
},
1589+
},
1590+
1 => match (2) {
1591+
1 => match (3) {
1592+
3 => 3,
1593+
default => -1,
1594+
},
1595+
2 => match (3) {
1596+
3 => 3,
1597+
default => -1,
1598+
},
1599+
},
1600+
};
1601+
1602+
// Issue #437.
1603+
match (true) {
1604+
default => [
1605+
'unrelated' => '',
1606+
'example' => array_filter(
1607+
array_map(
1608+
function () {
1609+
return null;
1610+
},
1611+
[]
1612+
)
1613+
)
1614+
]
1615+
};
1616+
15821617
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
15831618
?>
15841619

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,41 @@ foo(function ($foo) {
15791579
];
15801580
});
15811581

1582+
// Issue #110.
1583+
echo match (1) {
1584+
0 => match (2) {
1585+
2 => match (3) {
1586+
3 => 3,
1587+
default => -1,
1588+
},
1589+
},
1590+
1 => match (2) {
1591+
1 => match (3) {
1592+
3 => 3,
1593+
default => -1,
1594+
},
1595+
2 => match (3) {
1596+
3 => 3,
1597+
default => -1,
1598+
},
1599+
},
1600+
};
1601+
1602+
// Issue #437.
1603+
match (true) {
1604+
default => [
1605+
'unrelated' => '',
1606+
'example' => array_filter(
1607+
array_map(
1608+
function () {
1609+
return null;
1610+
},
1611+
[]
1612+
)
1613+
)
1614+
]
1615+
};
1616+
15821617
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
15831618
?>
15841619

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,41 @@ foo(function ($foo) {
15791579
];
15801580
});
15811581

1582+
// Issue #110.
1583+
echo match (1) {
1584+
0 => match (2) {
1585+
2 => match (3) {
1586+
3 => 3,
1587+
default => -1,
1588+
},
1589+
},
1590+
1 => match (2) {
1591+
1 => match (3) {
1592+
3 => 3,
1593+
default => -1,
1594+
},
1595+
2 => match (3) {
1596+
3 => 3,
1597+
default => -1,
1598+
},
1599+
},
1600+
};
1601+
1602+
// Issue #437.
1603+
match (true) {
1604+
default => [
1605+
'unrelated' => '',
1606+
'example' => array_filter(
1607+
array_map(
1608+
function () {
1609+
return null;
1610+
},
1611+
[]
1612+
)
1613+
)
1614+
]
1615+
};
1616+
15821617
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
15831618
?>
15841619

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,6 +1579,41 @@ foo(function ($foo) {
15791579
];
15801580
});
15811581

1582+
// Issue #110.
1583+
echo match (1) {
1584+
0 => match (2) {
1585+
2 => match (3) {
1586+
3 => 3,
1587+
default => -1,
1588+
},
1589+
},
1590+
1 => match (2) {
1591+
1 => match (3) {
1592+
3 => 3,
1593+
default => -1,
1594+
},
1595+
2 => match (3) {
1596+
3 => 3,
1597+
default => -1,
1598+
},
1599+
},
1600+
};
1601+
1602+
// Issue #437.
1603+
match (true) {
1604+
default => [
1605+
'unrelated' => '',
1606+
'example' => array_filter(
1607+
array_map(
1608+
function () {
1609+
return null;
1610+
},
1611+
[]
1612+
)
1613+
)
1614+
]
1615+
};
1616+
15821617
/* ADD NEW TESTS ABOVE THIS LINE AND MAKE SURE THAT THE 1 (space-based) AND 2 (tab-based) FILES ARE IN SYNC! */
15831618
?>
15841619

src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public function getErrorList($testFile='')
192192
1527 => 1,
193193
1529 => 1,
194194
1530 => 1,
195-
1590 => 1,
196-
1591 => 1,
197-
1592 => 1,
198-
1593 => 1,
195+
1625 => 1,
196+
1626 => 1,
197+
1627 => 1,
198+
1628 => 1,
199199
];
200200

201201
}//end getErrorList()

0 commit comments

Comments
 (0)