diff --git a/package.xml b/package.xml index 9fddb26f4e..a7bd4b357c 100644 --- a/package.xml +++ b/package.xml @@ -141,6 +141,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> -- Thanks to Juliette Reinders Folmer for the patch - Fixed bug #1769 : Custom "define" function triggers a warning about declaring new symbols - Fixed bug #1776 : Squiz.Scope.StaticThisUsage incorrectly looking inside anon classes + - Fixed bug #1777 : Generic.WhiteSpace.ScopeIndent incorrect indent errors when self called function proceeded by comment diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php index 56aaecc9eb..aaeb6968d2 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php @@ -325,10 +325,18 @@ public function process(File $phpcsFile, $stackPtr) echo "\t* first token on line $line is $first ($type) *".PHP_EOL; } - if ($first === $tokens[$parenCloser]['parenthesis_opener']) { + if ($first === $tokens[$parenCloser]['parenthesis_opener'] + && $tokens[($first - 1)]['line'] === $tokens[$first]['line'] + ) { // This is unlikely to be the start of the statement, so look // back further to find it. $first--; + if ($this->debug === true) { + $line = $tokens[$first]['line']; + $type = $tokens[$first]['type']; + echo "\t* first token is the parenthesis opener *".PHP_EOL; + echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL; + } } $prev = $phpcsFile->findStartOfStatement($first, T_COMMA); diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc index 0cf249ea24..6495db5138 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc @@ -1235,6 +1235,15 @@ array_map( $some_array ); +/** + * Comment. + */ +(function () use ($app) { + echo 'hi'; +})(); + +$app->run(); + public function foo() { $foo('some diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed index 0a1694d72c..234e31772d 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed @@ -1235,6 +1235,15 @@ array_map( $some_array ); +/** + * Comment. + */ +(function () use ($app) { + echo 'hi'; +})(); + +$app->run(); + public function foo() { $foo('some diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc index f16c4a4b3a..28cd8f144f 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc @@ -1235,6 +1235,15 @@ array_map( $some_array ); +/** + * Comment. + */ +(function () use ($app) { + echo 'hi'; +})(); + +$app->run(); + public function foo() { $foo('some diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed index af749ca1f2..83e3fda877 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed @@ -1235,6 +1235,15 @@ array_map( $some_array ); +/** + * Comment. + */ +(function () use ($app) { + echo 'hi'; +})(); + +$app->run(); + public function foo() { $foo('some diff --git a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php index 84d7325cbc..92cd1b64b2 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +++ b/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php @@ -141,15 +141,15 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc') 1163 => 1, 1197 => 1, 1198 => 1, - 1250 => 1, - 1254 => 1, 1259 => 1, - 1261 => 1, - 1264 => 1, + 1263 => 1, 1268 => 1, - 1269 => 1, 1270 => 1, - 1271 => 1, + 1273 => 1, + 1277 => 1, + 1278 => 1, + 1279 => 1, + 1280 => 1, ]; }//end getErrorList()