Skip to content

Commit

Permalink
Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is …
Browse files Browse the repository at this point in the history
…on a line by itself
  • Loading branch information
gsherwood committed Sep 15, 2015
1 parent dee5d3e commit b2c7832
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
echo "\t* first token on line $line is $type *".PHP_EOL;
}

if ($first === $tokens[$checkToken]['parenthesis_opener']) {
// This is unlikely to be the start of the statement, so look
// back further to find it.
$first--;
}

$prev = $phpcsFile->findStartOfStatement($first);
if ($prev !== $first) {
// This is not the start of the statement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ declare(ticks=1) {
echo 'foo';
}

$a =
(
$b = 1
);
$c = 2;

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ declare(ticks=1) {
echo 'foo';
}

$a =
(
$b = 1
);
$c = 2;

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ declare(ticks=1) {
echo 'foo';
}

$a =
(
$b = 1
);
$c = 2;

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,12 @@ declare(ticks=1) {
echo 'foo';
}

$a =
(
$b = 1
);
$c = 2;

function foo()
{
$foo = array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
862 => 1,
863 => 1,
879 => 1,
882 => 1,
894 => 1,
895 => 1,
897 => 1,
899 => 1,
888 => 1,
900 => 1,
901 => 1,
903 => 1,
905 => 1,
);

}//end getErrorList()
Expand Down
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #625 : Consider working around T_HASHBANG in HHVM 3.5.x and 3.6.x
-- Thanks to Kunal Mehta for the patch
- Fixed bug #694 : Long sniff codes can cause PHP warnings in source report when showing error codes
- Fixed bug #704 : ScopeIndent can fail when an opening parenthesis is on a line by itself
</notes>
<contents>
<dir name="/">
Expand Down

0 comments on commit b2c7832

Please sign in to comment.