|
@@ -63,7 +63,9 @@ class DocBlocks
|
|
|
|
|
|
protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
|
|
|
{
|
|
|
- foreach ($tokens as $index => $token) {
|
|
|
+ for ($index = $tokens->count() - 1; 0 <= $index; --$index) {
|
|
|
+ $token = $tokens[$index];
|
|
|
+
|
|
|
if (!$token->isGivenKind(T_DOC_COMMENT)) {
|
|
|
continue;
|
|
|
}
|
|
@@ -95,7 +97,13 @@ class DocBlocks
|
|
|
|
|
|
$newPrevContent = $this->fixWhitespaceBeforeDocblock($prevToken->getContent(), $indent);
|
|
|
|
|
|
- if ('' !== $newPrevContent) {
|
|
|
+ $tokens[$index] = new Token([T_DOC_COMMENT, $this->fixDocBlock($token->getContent(), $indent)]);
|
|
|
+
|
|
|
+ if (!$prevToken->isWhitespace()) {
|
|
|
+ if ('' !== $indent) {
|
|
|
+ $tokens->insertAt($index, new Token([T_WHITESPACE, $indent]));
|
|
|
+ }
|
|
|
+ } elseif ('' !== $newPrevContent) {
|
|
|
if ($prevToken->isArray()) {
|
|
|
$tokens[$prevIndex] = new Token([$prevToken->getId(), $newPrevContent]);
|
|
|
} else {
|
|
@@ -104,8 +112,6 @@ class DocBlocks
|
|
|
} else {
|
|
|
$tokens->clearAt($prevIndex);
|
|
|
}
|
|
|
-
|
|
|
- $tokens[$index] = new Token([T_DOC_COMMENT, $this->fixDocBlock($token->getContent(), $indent)]);
|
|
|
}
|
|
|
}
|
|
|
|