Просмотр исходного кода

PhpdocIndentFixer - fix edge case with inline phpdoc

Dariusz Ruminski 7 лет назад
Родитель
Сommit
101dc437f6
2 измененных файлов с 10 добавлено и 1 удалено
  1. 1 1
      src/Fixer/Phpdoc/PhpdocIndentFixer.php
  2. 9 0
      tests/Fixer/Phpdoc/PhpdocIndentFixerTest.php

+ 1 - 1
src/Fixer/Phpdoc/PhpdocIndentFixer.php

@@ -92,7 +92,7 @@ class DocBlocks
             if (
             if (
                 $prevToken->isGivenKind(T_OPEN_TAG)
                 $prevToken->isGivenKind(T_OPEN_TAG)
                 || ($prevToken->isWhitespace(" \t") && !$tokens[$index - 2]->isGivenKind(T_OPEN_TAG))
                 || ($prevToken->isWhitespace(" \t") && !$tokens[$index - 2]->isGivenKind(T_OPEN_TAG))
-                || $prevToken->equalsAny(array(';', '{'))
+                || $prevToken->equalsAny(array(';', ',', '{', '('))
             ) {
             ) {
                 continue;
                 continue;
             }
             }

+ 9 - 0
tests/Fixer/Phpdoc/PhpdocIndentFixerTest.php

@@ -381,6 +381,15 @@ $foo = $bar;
 ',
 ',
         );
         );
 
 
+        $cases[] = array(
+            '<?php
+function foo()
+{
+    $foo->bar(/** oops */$baz);
+    $foo->bar($a,/** oops */$baz);
+}',
+        );
+
         return $cases;
         return $cases;
     }
     }
 }
 }