diff --git a/src/Rector/RemoveMigrationDocBlockRector.php b/src/Rector/RemoveMigrationDocBlockRector.php new file mode 100644 index 00000000..4196e217 --- /dev/null +++ b/src/Rector/RemoveMigrationDocBlockRector.php @@ -0,0 +1,82 @@ +getDocComment(); + if ($docComment === null) { + return null; + } + + // Additional safety: only process up() and down() methods in migrations + $methodName = $node->name->toString(); + if (!in_array($methodName, ['up', 'down'])) { + return null; + } + + // Check for standard migration docblocks + $patterns = [ + '/\/\*\*\s*\n\s*\*\s*Run the migrations\.\s*(\n\s*\*\s*\n\s*\*\s*@return void\s*)?\n\s*\*\//', + '/\/\*\*\s*\n\s*\*\s*Reverse the migrations\.\s*(\n\s*\*\s*\n\s*\*\s*@return void\s*)?\n\s*\*\//' + ]; + + $docText = $docComment->getText(); + foreach ($patterns as $pattern) { + if (preg_match($pattern, $docText)) { + $node->setAttribute('comments', []); + + return $node; + } + } + + return null; + } +}