Skip to content

Commit

Permalink
Fixed bug #945 : Incorrect indent behavior using deep-nested function…
Browse files Browse the repository at this point in the history
… and arrays
  • Loading branch information
gsherwood committed May 31, 2016
1 parent 59cfbc2 commit d38b2f5
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)

$parenOpener = $tokens[$parenCloser]['parenthesis_opener'];
if ($tokens[$parenCloser]['line'] !== $tokens[$parenOpener]['line']) {
if (isset($tokens[$parenCloser]['nested_parenthesis']) === true
&& empty($tokens[$parenCloser]['nested_parenthesis']) === false
) {
end($tokens[$parenCloser]['nested_parenthesis']);
$parenOpener = key($tokens[$parenCloser]['nested_parenthesis']);
if ($this->_debug === true) {
$line = $tokens[$parens]['line'];
echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
echo "\t* using parenthesis *".PHP_EOL;
}
}

$first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true);
$checkIndent = ($tokens[$first]['column'] - 1);
if (isset($adjustments[$first]) === true) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,15 @@ class SomeClass
}
}

$params = self::validate_parameters(self::read_competency_framework_parameters(),
array(
'id' => $id,
));

$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
$output = $PAGE->get_renderer('tool_lp');

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,15 @@ class SomeClass
}
}

$params = self::validate_parameters(self::read_competency_framework_parameters(),
array(
'id' => $id,
));

$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
$output = $PAGE->get_renderer('tool_lp');

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,15 @@ class SomeClass
}
}

$params = self::validate_parameters(self::read_competency_framework_parameters(),
array(
'id' => $id,
));

$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
$output = $PAGE->get_renderer('tool_lp');

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,15 @@ class SomeClass
}
}

$params = self::validate_parameters(self::read_competency_framework_parameters(),
array(
'id' => $id,
));

$framework = api::read_framework($params['id']);
self::validate_context($framework->get_context());
$output = $PAGE->get_renderer('tool_lp');

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
823 => 1,
858 => 1,
879 => 1,
1056 => 1,
1061 => 1,
1063 => 1,
1066 => 1,
1065 => 1,
1070 => 1,
1072 => 1,
1075 => 1,
);

}//end getErrorList()
Expand Down
3 changes: 2 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ http://pear.php.net/dtd/package-2.0.xsd">
</stability>
<license uri="https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt">BSD 3-Clause License</license>
<notes>
- Fixed bug ##961 : Two anonymous functions passed as function/method arguments cause indentation false positive
- Fixed bug #945 : Incorrect indent behavior using deep-nested function and arrays
- Fixed bug #961 : Two anonymous functions passed as function/method arguments cause indentation false positive
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit d38b2f5

Please sign in to comment.