Browse Source

Merge branch '2.2' into 2.10

# Conflicts:
#	src/Fixer/Phpdoc/GeneralPhpdocAnnotationRemoveFixer.php
#	tests/Fixer/Phpdoc/GeneralPhpdocAnnotationRemoveFixerTest.php
Dariusz Ruminski 7 years ago
parent
commit
daa7e71d0d

+ 5 - 1
src/Fixer/Phpdoc/GeneralPhpdocAnnotationRemoveFixer.php

@@ -94,7 +94,11 @@ function foo() {}
                 $annotation->remove();
             }
 
-            $tokens[$index] = new Token([T_DOC_COMMENT, $doc->getContent()]);
+            if ('' === $doc->getContent()) {
+                $tokens->clearTokenAndMergeSurroundingWhitespace($index);
+            } else {
+                $tokens[$index] = new Token([T_DOC_COMMENT, $doc->getContent()]);
+            }
         }
     }
 

+ 11 - 0
tests/Fixer/Phpdoc/GeneralPhpdocAnnotationRemoveFixerTest.php

@@ -172,6 +172,17 @@ function hello($name)
                 null,
                 ['annotations' => ['author', 'test', 'return', 'deprecated']],
             ],
+            [
+                '<?php
+
+while ($something = myFunction($foo)) {}
+',
+                '<?php
+/** @noinspection PhpAssignmentInConditionInspection */
+while ($something = myFunction($foo)) {}
+',
+                ['annotations' => ['noinspection']],
+            ],
         ];
     }
 }