Skip to content

Commit 042b6bf

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: [BrowserKit] Merge fields and files recursively if they are multidimensional array [String] Fix `width` method in `AbstractUnicodeString` [Mailer] Add a comment to avoid the same wrong PR over and over again [Serializer] Fix XmlEncoder encoding attribute false
2 parents 5c7621e + 5eb661e commit 042b6bf

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

AbstractUnicodeString.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,11 @@ public function width(bool $ignoreAnsiDecoration = true): int
484484
)|[\p{Cc}\x7F]++)/xu', '', $s);
485485
}
486486

487-
// Non printable characters have been dropped, so wcswidth cannot logically return -1.
488-
$width += $this->wcswidth($s);
487+
$lineWidth = $this->wcswidth($s);
488+
489+
if ($lineWidth > $width) {
490+
$width = $lineWidth;
491+
}
489492
}
490493

491494
return $width;

Tests/AbstractUnicodeTestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@
1515

1616
abstract class AbstractUnicodeTestCase extends AbstractAsciiTestCase
1717
{
18+
public static function provideWidth(): array
19+
{
20+
return array_merge(
21+
parent::provideWidth(),
22+
[
23+
[14, '<<<END
24+
This is a
25+
multiline text
26+
END'],
27+
]
28+
);
29+
}
30+
1831
public function testCreateFromStringWithInvalidUtf8Input()
1932
{
2033
$this->expectException(InvalidArgumentException::class);

0 commit comments

Comments
 (0)