Skip to content

Commit 158ee42

Browse files
committed
Fixed bug #1221 : Indented function call with multiple closure arguments can cause scope indent error
1 parent 068e113 commit 158ee42

File tree

7 files changed

+34
-7
lines changed

7 files changed

+34
-7
lines changed

Diff for: CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
236236
&& $tokens[$checkToken]['code'] === T_CLOSE_PARENTHESIS
237237
&& isset($tokens[$checkToken]['parenthesis_opener']) === true)
238238
|| ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS
239-
&& isset($tokens[$i]['parenthesis_opener']) === true
240-
&& isset($tokens[$i]['parenthesis_owner']) === true
241-
&& $tokens[$tokens[$i]['parenthesis_owner']]['code'] === T_ARRAY)
239+
&& isset($tokens[$i]['parenthesis_opener']) === true)
242240
) {
243241
if ($checkToken !== null) {
244242
$parenCloser = $checkToken;

Diff for: CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc

+7
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,13 @@ $foo = [
11351135
},
11361136
];
11371137

1138+
$foo
1139+
->bar(foo(function () {
1140+
}), foo(function () {
1141+
}));
1142+
1143+
echo 'foo';
1144+
11381145
class Test {
11391146

11401147
public function a() {

Diff for: CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed

+7
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,13 @@ $foo = [
11351135
},
11361136
];
11371137

1138+
$foo
1139+
->bar(foo(function () {
1140+
}), foo(function () {
1141+
}));
1142+
1143+
echo 'foo';
1144+
11381145
class Test {
11391146

11401147
public function a() {

Diff for: CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc

+7
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,13 @@ $foo = [
11351135
},
11361136
];
11371137

1138+
$foo
1139+
->bar(foo(function () {
1140+
}), foo(function () {
1141+
}));
1142+
1143+
echo 'foo';
1144+
11381145
class Test {
11391146

11401147
public function a() {

Diff for: CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed

+7
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,13 @@ $foo = [
11351135
},
11361136
];
11371137

1138+
$foo
1139+
->bar(foo(function () {
1140+
}), foo(function () {
1141+
}));
1142+
1143+
echo 'foo';
1144+
11381145
class Test {
11391146

11401147
public function a() {

Diff for: CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
154154
823 => 1,
155155
858 => 1,
156156
879 => 1,
157-
1156 => 1,
158-
1164 => 1,
159-
1169 => 1,
157+
1163 => 1,
160158
1171 => 1,
161-
1174 => 1,
159+
1176 => 1,
160+
1178 => 1,
161+
1181 => 1,
162162
);
163163

164164
}//end getErrorList()

Diff for: package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
5454
- Fixed bug #1191 : Javascript sniffer fails with function called "Function"
5555
- Fixed bug #1203 : Inconsistent behavior of PHP_CodeSniffer_File::findEndOfStatement
5656
- Fixed bug #1218 : CASE conditions using class constants named NAMESPACE/INTERFACE/TRAIT etc are incorrectly tokenized
57+
- Fixed bug #1221 : Indented function call with multiple closure arguments can cause scope indent error
5758
</notes>
5859
<contents>
5960
<dir name="/">

0 commit comments

Comments
 (0)