Skip to content

Commit

Permalink
minor #4987 PhpdocAnnotationWithoutDotFixer - handle unicode characte…
Browse files Browse the repository at this point in the history
…rs using mb_* (SpacePossum)

This PR was merged into the 2.15 branch.

Discussion
----------

PhpdocAnnotationWithoutDotFixer - handle unicode characters using mb_*

replaces #4977

Commits
-------

6d99931 PhpdocAnnotationWithoutDotFixer - handle unicode characters using mb_*
  • Loading branch information
SpacePossum committed Jun 14, 2020
2 parents 31baa00 + 6d99931 commit 2920da6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"suggest": {
"ext-dom": "For handling output formats in XML",
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
"ext-mbstring": "For handling non-UTF8 characters.",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.",
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
Expand Down
4 changes: 4 additions & 0 deletions src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
$content = Preg::replaceCallback(
'/^(\s*\*\s*@\w+\s+'.$optionalTypeRegEx.')(\p{Lu}?(?=\p{Ll}|\p{Zs}))(.*)$/',
static function (array $matches) {
if (\function_exists('mb_strtolower')) {
return $matches[1].mb_strtolower($matches[2]).$matches[3];
}

return $matches[1].strtolower($matches[2]).$matches[3];
},
$startLine->getContent(),
Expand Down
14 changes: 14 additions & 0 deletions tests/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,20 @@ function foo($str) {}',
*/
function nothingToDo() {}',
],
[
'<?php
/**
* @param string $bar τάχιστη
*/
function foo ($bar) {}
',
'<?php
/**
* @param string $bar Τάχιστη.
*/
function foo ($bar) {}
',
],
];
}
}

0 comments on commit 2920da6

Please sign in to comment.