Skip to content

Commit 13880a8

Browse files
committedNov 9, 2023
Merge branch '5.4' into 6.3
* 5.4: [Config] Prefixing FileExistenceResource::__toString() to avoid conflict with FileResource [String] Method toByteString conversion using iconv is unreachable [HttpKernel] Fix PHP deprecation
2 parents 13d76d0 + 2765096 commit 13880a8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
 

‎AbstractString.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,11 @@ public function toByteString(string $toEncoding = null): ByteString
512512
try {
513513
try {
514514
$b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
515-
} catch (InvalidArgumentException $e) {
515+
} catch (InvalidArgumentException|\ValueError $e) {
516516
if (!\function_exists('iconv')) {
517+
if ($e instanceof \ValueError) {
518+
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
519+
}
517520
throw $e;
518521
}
519522

‎Tests/AbstractAsciiTestCase.php

+18
Original file line numberDiff line numberDiff line change
@@ -1581,4 +1581,22 @@ public static function provideWidth(): array
15811581
[17, "\u{007f}\u{007f}f\u{001b}[0moo\u{0001}bar\u{007f}cccïf\u{008e}cy\u{0005}1", false], // f[0moobarcccïfcy1
15821582
];
15831583
}
1584+
1585+
/**
1586+
* @dataProvider provideToByteString
1587+
*/
1588+
public function testToByteString(string $origin, string $encoding)
1589+
{
1590+
$instance = static::createFromString($origin)->toByteString($encoding);
1591+
$this->assertInstanceOf(ByteString::class, $instance);
1592+
}
1593+
1594+
public static function provideToByteString(): array
1595+
{
1596+
return [
1597+
['žsžsý', 'UTF-8'],
1598+
['žsžsý', 'windows-1250'],
1599+
['žsžsý', 'Windows-1252'],
1600+
];
1601+
}
15841602
}

0 commit comments

Comments
 (0)
Please sign in to comment.