|
36 | 36 | * @implements ConfigurableFixerInterface<_AutogeneratedInputConfiguration, _AutogeneratedComputedConfiguration> |
37 | 37 | * |
38 | 38 | * @phpstan-type _AutogeneratedInputConfiguration array{ |
39 | | - * stick_comment_to_next_continuous_control_statement?: bool |
| 39 | + * stick_comment_to_next_continuous_control_statement?: bool, |
40 | 40 | * } |
41 | 41 | * @phpstan-type _AutogeneratedComputedConfiguration array{ |
42 | | - * stick_comment_to_next_continuous_control_statement: bool |
| 42 | + * stick_comment_to_next_continuous_control_statement: bool, |
43 | 43 | * } |
44 | 44 | */ |
45 | 45 | final class StatementIndentationFixer extends AbstractFixer implements ConfigurableFixerInterface, WhitespacesAwareFixerInterface |
@@ -171,7 +171,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void |
171 | 171 | $blockSignatureFirstTokens[] = T_MATCH; |
172 | 172 | } |
173 | 173 |
|
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]]; |
175 | 175 | if (\defined('T_ATTRIBUTE')) { // @TODO: drop condition when PHP 8.0+ is required |
176 | 176 | $blockFirstTokens[] = [T_ATTRIBUTE]; |
177 | 177 | } |
@@ -222,7 +222,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void |
222 | 222 | $scopes[] = [ |
223 | 223 | 'type' => 'block', |
224 | 224 | 'skip' => false, |
225 | | - 'end_index' => $this->findStatementEndIndex($tokens, $index, \count($tokens) - 1), |
| 225 | + 'end_index' => $this->findStatementEndIndex($tokens, $index, \count($tokens) - 1) + 1, |
226 | 226 | 'end_index_inclusive' => true, |
227 | 227 | 'initial_indent' => $this->getLineIndentationWithBracesCompatibility($tokens, $index, $lastIndent), |
228 | 228 | 'is_indented_block' => true, |
@@ -256,6 +256,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void |
256 | 256 | $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $index); |
257 | 257 | } elseif ($token->equals('(')) { |
258 | 258 | $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]]); |
259 | 261 | } else { |
260 | 262 | $endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_ATTRIBUTE, $index); |
261 | 263 | } |
|
0 commit comments