Skip to content

Commit

Permalink
Fixed bug #2632 : Incorrect indentation of lines starting with static…
Browse files Browse the repository at this point in the history
… inside closures
  • Loading branch information
gsherwood committed Oct 9, 2019
1 parent 52e9819 commit f5dc023
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
- Fixed bug #2624 : PSR12.Traits.UseDeclaration doesnt apply the correct indent during auto fixing
- Fixed bug #2626 : PSR12.Files.FileHeader detects @var annotations as file docblocks
- Fixed bug #2628 : PSR12.Traits.UseDeclaration does not allow comments above a USE declaration
- Fixed bug #2632 : Incorrect indentation of lines starting with "static" inside closures
- Fixed bug #2641 : PSR12.Functions.NullableTypeDeclaration false positive when using new static()
</notes>
<contents>
Expand Down
5 changes: 4 additions & 1 deletion src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,10 @@ public function process(File $phpcsFile, $stackPtr)
&& $tokens[($checkToken + 1)]['code'] !== T_DOUBLE_COLON
) {
$next = $phpcsFile->findNext(Tokens::$emptyTokens, ($checkToken + 1), null, true);
if ($next === false || $tokens[$next]['code'] !== T_CLOSURE) {
if ($next === false
|| ($tokens[$next]['code'] !== T_CLOSURE
&& $tokens[$next]['code'] !== T_VARIABLE)
) {
if ($this->debug === true) {
$line = $tokens[$checkToken]['line'];
$type = $tokens[$checkToken]['type'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,11 @@ FOO
$a,
];

$query = Model::query()
->when($a, function () {
static $b = '';
});

?>

<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,11 @@ FOO
$a,
];

$query = Model::query()
->when($a, function () {
static $b = '';
});

?>

<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,11 @@ FOO
$a,
];

$query = Model::query()
->when($a, function () {
static $b = '';
});

?>

<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,11 @@ FOO
$a,
];

$query = Model::query()
->when($a, function () {
static $b = '';
});

?>

<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ public function getErrorList($testFile='ScopeIndentUnitTest.inc')
1340 => 1,
1342 => 1,
1345 => 1,
1435 => 1,
1436 => 1,
1437 => 1,
1438 => 1,
1440 => 1,
1441 => 1,
1442 => 1,
1443 => 1,
];

}//end getErrorList()
Expand Down

0 comments on commit f5dc023

Please sign in to comment.