diff --git a/packages/ReflectionDocBlock/src/NodeAnalyzer/DocBlockAnalyzer.php b/packages/ReflectionDocBlock/src/NodeAnalyzer/DocBlockAnalyzer.php index d460abf7bbe..5d1dc02631c 100644 --- a/packages/ReflectionDocBlock/src/NodeAnalyzer/DocBlockAnalyzer.php +++ b/packages/ReflectionDocBlock/src/NodeAnalyzer/DocBlockAnalyzer.php @@ -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); diff --git a/src/Rector/Dynamic/ValueObjectRemoverRector.php b/src/Rector/Dynamic/ValueObjectRemoverRector.php index 1c515128232..ddc1aea0406 100644 --- a/src/Rector/Dynamic/ValueObjectRemoverRector.php +++ b/src/Rector/Dynamic/ValueObjectRemoverRector.php @@ -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) );