Skip to content

Commit 6ab01ef

Browse files
authored
fix: PhpdocAlignFixer - align correctly type with UTF8 characters (#8486)
1 parent 2f7ae4d commit 6ab01ef

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Fixer/Phpdoc/PhpdocAlignFixer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private function fixDocBlock(DocBlock $docBlock): void
379379
.$item['hint'];
380380

381381
if ('' !== $item['var']) {
382-
$line .= $this->getIndent((0 !== $hintMax ? $hintMax : -1) - \strlen($item['hint']) + $spacingForTag, $spacingForTag)
382+
$line .= $this->getIndent((0 !== $hintMax ? $hintMax : -1) - mb_strlen($item['hint']) + $spacingForTag, $spacingForTag)
383383
.$item['var']
384384
.(
385385
'' !== $item['desc']

tests/Fixer/Phpdoc/PhpdocAlignFixerTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,24 @@ function foo($typeless): void {}',
15201520
*/
15211521
',
15221522
];
1523+
1524+
yield 'type with UTF8 characters' => [
1525+
['tags' => ['param'], 'align' => PhpdocAlignFixer::ALIGN_VERTICAL],
1526+
<<<'PHP'
1527+
<?php
1528+
/**
1529+
* @param Foooooooooooooooo $x
1530+
* @param Bar‹Baz› $y
1531+
*/
1532+
PHP,
1533+
<<<'PHP'
1534+
<?php
1535+
/**
1536+
* @param Foooooooooooooooo $x
1537+
* @param Bar‹Baz› $y
1538+
*/
1539+
PHP,
1540+
];
15231541
}
15241542

15251543
/**

0 commit comments

Comments
 (0)