keep original info at doc block

This commit is contained in:
TomasVotruba 2018-03-11 19:53:44 +01:00 committed by Tomas Votruba
parent c8d45616c0
commit 71bcc39de1
2 changed files with 8 additions and 12 deletions

View File

@ -67,10 +67,12 @@ final class DocBlockAnalyzer
return;
}
$content = $node->getDocComment()->getText();
$docComment = $node->getDocComment();
$content = $docComment->getText();
$newContent = Strings::replace($content, '#' . preg_quote($old, '#') . '#', $new, 1);
$doc = new Doc($newContent);
$doc = new Doc($newContent, $docComment->getLine(), $docComment->getFilePos(), $docComment->getTokenPos());
$node->setDocComment($doc);
}
@ -84,12 +86,7 @@ final class DocBlockAnalyzer
$oldAnnotationPattern = preg_quote(sprintf('#@%s#', $oldAnnotation), '\\');
$newContent = Strings::replace(
$oldContent,
$oldAnnotationPattern,
'@' . $newAnnotation,
1
);
$newContent = Strings::replace($oldContent, $oldAnnotationPattern, '@' . $newAnnotation, 1);
$doc = new Doc($newContent);
$node->setDocComment($doc);

View File

@ -161,7 +161,6 @@ final class ValueObjectRemoverRector extends AbstractRector
return $node;
}
return null;
}
@ -211,7 +210,6 @@ final class ValueObjectRemoverRector extends AbstractRector
continue;
}
dump($nodeType);
return $this->valueObjectsToSimpleTypes[$nodeType];
}
@ -228,7 +226,7 @@ final class ValueObjectRemoverRector extends AbstractRector
return [
$nodeType,
$this->valueObjectsToSimpleTypes[$nodeType]
$this->valueObjectsToSimpleTypes[$nodeType],
];
}
@ -237,7 +235,8 @@ final class ValueObjectRemoverRector extends AbstractRector
private function renameNullableInDocBlock(Node $node, string $oldType, string $newType): void
{
$this->docBlockAnalyzer->replaceInNode($node,
$this->docBlockAnalyzer->replaceInNode(
$node,
sprintf('%s|null', $oldType),
sprintf('%s|null', $newType)
);