Dariusz Ruminski 7 лет назад
Родитель
Сommit
2feb1e95c5

+ 8 - 3
src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php

@@ -90,9 +90,14 @@ function foo ($bar) {}
                 $optionalTypeRegEx = $annotation->supportTypes()
                     ? sprintf('(?:%s\s+(?:\$\w+\s+)?)?', preg_quote(implode('|', $annotation->getTypes())))
                     : '';
-                $content = preg_replace_callback('/^(\s*\*\s*@\w+\s+'.$optionalTypeRegEx.')(.*)$/', function (array $matches) {
-                    return $matches[1].lcfirst($matches[2]);
-                }, $startLine->getContent(), 1);
+                $content = preg_replace_callback(
+                    '/^(\s*\*\s*@\w+\s+'.$optionalTypeRegEx.')(\p{Lu}?(?=\p{Ll}|\p{Zs}))(.*)$/',
+                    function (array $matches) {
+                        return $matches[1].strtolower($matches[2]).$matches[3];
+                    },
+                    $startLine->getContent(),
+                    1
+                );
                 $startLine->setContent($content);
             }
 

+ 12 - 0
tests/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixerTest.php

@@ -45,6 +45,12 @@ final class PhpdocAnnotationWithoutDotFixerTest extends AbstractFixerTestCase
      * Description.
      *
      * @param string|null $str   some string
+     * @param string $ip         IPv4 is not lowercased
+     * @param string $a          A
+     * @param string $a_string   a string
+     * @param string $ab         ab
+     * @param string $t34        T34
+     * @param string $s          S§
      * @param string $genrb      Optional. The path to the "genrb" executable
      * @param string $ellipsis1  Ellipsis is this: ...
      * @param string $ellipsis2  Ellipsis is this: 。。。
@@ -64,6 +70,12 @@ final class PhpdocAnnotationWithoutDotFixerTest extends AbstractFixerTestCase
      * Description.
      *
      * @param string|null $str   Some string.
+     * @param string $ip         IPv4 is not lowercased.
+     * @param string $a          A.
+     * @param string $a_string   A string.
+     * @param string $ab         Ab.
+     * @param string $t34        T34.
+     * @param string $s          S§.
      * @param string $genrb      Optional. The path to the "genrb" executable
      * @param string $ellipsis1  Ellipsis is this: ...
      * @param string $ellipsis2  Ellipsis is this: 。。。