diff --git a/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 605d4e7601..62047d0a24 100644 --- a/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -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. diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc index 0571a70ad8..5a6f6734a3 100644 --- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc +++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc @@ -879,6 +879,12 @@ declare(ticks=1) { echo 'foo'; } +$a = + ( + $b = 1 + ); +$c = 2; + function foo() { $foo = array( diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed index bfa96e2664..198aeeb37c 100644 --- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed +++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed @@ -879,6 +879,12 @@ declare(ticks=1) { echo 'foo'; } +$a = + ( + $b = 1 + ); +$c = 2; + function foo() { $foo = array( diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc index 9b66221113..94d24a7f10 100644 --- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc +++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc @@ -879,6 +879,12 @@ declare(ticks=1) { echo 'foo'; } +$a = + ( + $b = 1 + ); +$c = 2; + function foo() { $foo = array( diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed index 2994520ee7..59f75b5c1c 100644 --- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed +++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed @@ -879,6 +879,12 @@ declare(ticks=1) { echo 'foo'; } +$a = + ( + $b = 1 + ); +$c = 2; + function foo() { $foo = array( diff --git a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 7814474ad5..20a9ef0285 100644 --- a/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/CodeSniffer/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -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() diff --git a/package.xml b/package.xml index 886adf1b16..1dbf71837c 100644 --- a/package.xml +++ b/package.xml @@ -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