Skip to content

Commit 79c5a18

Browse files
authored
Merge pull request #1158 from rodrigoprimo/fix-object-operator-indent
PEAR/ObjectOperatorIndent: improve end of statement detection when getting the next object operator
2 parents 368817d + 0b13c2b commit 79c5a18

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,7 @@ public function process(File $phpcsFile, $stackPtr)
191191
$next = $phpcsFile->findNext(
192192
$this->targets,
193193
($next + 1),
194-
null,
195-
false,
196-
null,
197-
true
194+
$end
198195
);
199196
}//end while
200197

src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@ $someObject
140140
->someOtherFunc(nameA: 23, nameB: 42)
141141
->endSomething($value, name: $value)
142142
->endEverything();
143+
144+
// Issue https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1154
145+
$array = [
146+
[
147+
$item->one()->two(),
148+
],
149+
$item->one()
150+
->two(),
151+
$item->one()
152+
->two(),
153+
];

src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc.fixed

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,14 @@ $someObject
140140
->someOtherFunc(nameA: 23, nameB: 42)
141141
->endSomething($value, name: $value)
142142
->endEverything();
143+
144+
// Issue https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/1154
145+
$array = [
146+
[
147+
$item->one()->two(),
148+
],
149+
$item->one()
150+
->two(),
151+
$item->one()
152+
->two(),
153+
];

src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function getErrorList()
5656
140 => 1,
5757
141 => 1,
5858
142 => 1,
59+
152 => 1,
5960
];
6061

6162
}//end getErrorList()

0 commit comments

Comments
 (0)