Skip to content

Commit 6e315f1

Browse files
committed
Generic.WhiteSpace.ScopeIndent now disables exact indent checking for multi-line chained methods (ref #2371)
1 parent cbe9b4e commit 6e315f1

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,15 @@ public function process(File $phpcsFile, $stackPtr)
903903
$exact = true;
904904
}
905905

906+
// Don't perform strict checking on chained method calls since they
907+
// are often covered by custom rules.
908+
if ($checkToken !== null
909+
&& $tokens[$checkToken]['code'] === T_OBJECT_OPERATOR
910+
&& $exact === true
911+
) {
912+
$exact = false;
913+
}
914+
906915
if ($checkIndent === null) {
907916
$checkIndent = $currentIndent;
908917
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,9 @@ function foo() {
13111311
if ($foo) {
13121312
echo 'baz';
13131313
}
1314+
$this->foo()
1315+
->bar()
1316+
->baz();
13141317
}
13151318
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
13161319

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,9 @@ function foo() {
13111311
if ($foo) {
13121312
echo 'baz';
13131313
}
1314+
$this->foo()
1315+
->bar()
1316+
->baz();
13141317
}
13151318
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
13161319

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,9 @@ function foo() {
13111311
if ($foo) {
13121312
echo 'baz';
13131313
}
1314+
$this->foo()
1315+
->bar()
1316+
->baz();
13141317
}
13151318
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
13161319

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,6 +1311,9 @@ function foo() {
13111311
if ($foo) {
13121312
echo 'baz';
13131313
}
1314+
$this->foo()
1315+
->bar()
1316+
->baz();
13141317
}
13151318
// phpcs:set Generic.WhiteSpace.ScopeIndent exact false
13161319

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,20 +164,21 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
164164
1293 => 1,
165165
1310 => 1,
166166
1312 => 1,
167-
1327 => 1,
168-
1328 => 1,
169-
1329 => 1,
167+
1315 => 1,
170168
1330 => 1,
171169
1331 => 1,
172170
1332 => 1,
171+
1333 => 1,
172+
1334 => 1,
173173
1335 => 1,
174-
1340 => 1,
175-
1342 => 1,
174+
1338 => 1,
175+
1343 => 1,
176176
1345 => 1,
177-
1364 => 1,
178-
1365 => 1,
179-
1366 => 1,
177+
1348 => 1,
180178
1367 => 1,
179+
1368 => 1,
180+
1369 => 1,
181+
1370 => 1,
181182
];
182183

183184
}//end getErrorList()

0 commit comments

Comments
 (0)