@@ -79,7 +79,7 @@ public function getConfigurationDefinition(): FixerConfigurationResolverInterfac
7979 ->getOption (),
8080 (new FixerOptionBuilder ('separate ' , 'Separate the comment ' ))
8181 ->setAllowedValues (Separate::getList ())
82- ->setDefault (Separate::Both ->value )
82+ ->setDefault (Separate::None ->value )
8383 ->getOption (),
8484 (new FixerOptionBuilder ('add_class_name ' , 'Add class name before annotations ' ))
8585 ->setAllowedTypes (['bool ' ])
@@ -202,7 +202,7 @@ private function replaceDocBlock(Tokens $tokens, int $docBlockIndex, array $anno
202202 */
203203 private function insertNewDocBlock (Tokens $ tokens , int $ classIndex , array $ annotations , string $ className ): void
204204 {
205- $ separate = $ this ->resolvedConfiguration ['separate ' ] ?? 'both ' ;
205+ $ separate = $ this ->resolvedConfiguration ['separate ' ] ?? 'none ' ;
206206 $ insertIndex = $ this ->findInsertPosition ($ tokens , $ classIndex );
207207
208208 $ tokensToInsert = [];
@@ -216,9 +216,14 @@ private function insertNewDocBlock(Tokens $tokens, int $classIndex, array $annot
216216 $ docBlock = $ this ->buildDocBlock ($ annotations , $ className );
217217 $ tokensToInsert [] = new Token ([T_DOC_COMMENT , $ docBlock ]);
218218
219- // Add separation after comment if needed
219+ // For compatibility with no_blank_lines_after_phpdoc, only add bottom separation when 'separate' is not 'none'
220+ // This prevents conflicts with PHP-CS-Fixer rules that manage DocBlock spacing
220221 if (in_array ($ separate , ['bottom ' , 'both ' ], true )) {
221- $ tokensToInsert [] = new Token ([T_WHITESPACE , "\n" ]);
222+ // Check if there's already whitespace after the class declaration
223+ $ nextToken = $ tokens [$ classIndex ] ?? null ;
224+ if (null !== $ nextToken && !$ nextToken ->isWhitespace ()) {
225+ $ tokensToInsert [] = new Token ([T_WHITESPACE , "\n" ]);
226+ }
222227 }
223228
224229 $ tokens ->insertAt ($ insertIndex , $ tokensToInsert );
@@ -296,7 +301,7 @@ private function buildDocBlock(array $annotations, string $className): string
296301 if ($ addClassName && !empty ($ className )) {
297302 $ docBlock .= " * {$ className }. \n" ;
298303
299- // Add empty line after class name if there are annotations
304+ // Add empty line after class name if there are annotations - compatible with phpdoc_separation
300305 if (!empty ($ annotations )) {
301306 $ docBlock .= " * \n" ;
302307 }
0 commit comments