Skip to content

Commit 8a36cc3

Browse files
committed
updated StatementIndentationFixer
1 parent 65ca941 commit 8a36cc3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Fixer/StatementIndentationFixer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
* @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration>
3737
*
3838
* @phpstan-type _AutogeneratedInputConfiguration array{
39-
* stick_comment_to_next_continuous_control_statement?: bool
39+
* stick_comment_to_next_continuous_control_statement?: bool,
4040
* }
4141
* @phpstan-type _AutogeneratedComputedConfiguration array{
42-
* stick_comment_to_next_continuous_control_statement: bool
42+
* stick_comment_to_next_continuous_control_statement: bool,
4343
* }
4444
*/
4545
final class StatementIndentationFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface
@@ -171,7 +171,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
171171
$blockSignatureFirstTokens[] = T_MATCH;
172172
}
173173

174-
$blockFirstTokens = ['{', [CT::T_DESTRUCTURING_SQUARE_BRACE_OPEN], [CT::T_USE_TRAIT], [CT::T_GROUP_IMPORT_BRACE_OPEN]];
174+
$blockFirstTokens = ['{', [CT::T_DESTRUCTURING_SQUARE_BRACE_OPEN], [CT::T_USE_TRAIT], [CT::T_GROUP_IMPORT_BRACE_OPEN], [CT::T_PROPERTY_HOOK_BRACE_OPEN]];
175175
if (\defined('T_ATTRIBUTE')) { // @TODO: drop condition when PHP 8.0+ is required
176176
$blockFirstTokens[] = [T_ATTRIBUTE];
177177
}
@@ -222,7 +222,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
222222
$scopes[] = [
223223
'type' => 'block',
224224
'skip' => false,
225-
'end_index' => $this->findStatementEndIndex($tokens, $index, \count($tokens) - 1),
225+
'end_index' => $this->findStatementEndIndex($tokens, $index, \count($tokens) - 1) + 1,
226226
'end_index_inclusive' => true,
227227
'initial_indent' => $this->getLineIndentationWithBracesCompatibility($tokens, $index, $lastIndent),
228228
'is_indented_block' => true,
@@ -256,6 +256,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
256256
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index);
257257
} elseif ($token->equals('(')) {
258258
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $index);
259+
} elseif ($token->isGivenKind(CT::T_PROPERTY_HOOK_BRACE_OPEN)) {
260+
$endIndex = $tokens->getNextTokenOfKind($index, [[CT::T_PROPERTY_HOOK_BRACE_CLOSE]]);
259261
} else {
260262
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ATTRIBUTE, $index);
261263
}

0 commit comments

Comments
 (0)