Skip to content

Commit

Permalink
Support multi-line arrays within chained calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Warren Seymour committed Jan 1, 2014
1 parent 4ba6d80 commit aeba35f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/rules/HasCorrectTabIndention.php
Expand Up @@ -140,6 +140,17 @@ protected function _getPredictedIndent($lineIndex, $testable) {
$expectedTab += 1; $expectedTab += 1;
} }


if ($inArray) {
$grandParent = $parent['parent'] > -1 ? $tokens[$parent['parent']] : null;
if ($grandParent !== null) {
$grandParentLine = trim($lines[$grandParent['line'] - 1]);

if (preg_match('/^->/', $grandParentLine)) {
$expectedTab += 1;
}
}
}

return array( return array(
'minSpace' => $minExpectedSpace, 'minSpace' => $minExpectedSpace,
'tab' => $expectedTab 'tab' => $expectedTab
Expand Down
12 changes: 12 additions & 0 deletions tests/cases/test/rules/HasCorrectTabIndentionTest.php
Expand Up @@ -477,6 +477,18 @@ public function testMultiLineChaining() {
$this->assertRulePass($code, $this->rule); $this->assertRulePass($code, $this->rule);
} }


public function testMultiLineChainingWithArrays() {
$code = <<<EOD
\$result = \$chain->called('method1')
->called('method2')
->with('first', array(
'id' => 100
))
->success();
EOD;
$this->assertRulePass($code, $this->rule);
}

public function testMutlilineAssignment() { public function testMutlilineAssignment() {
$code = <<<EOD $code = <<<EOD
return true || return true ||
Expand Down

0 comments on commit aeba35f

Please sign in to comment.