Skip to content

Commit 54398ed

Browse files
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 3922e80 + 9b2c2a4 commit 54398ed

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

src/Symfony/Component/Config/Resource/FileExistenceResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct(string $resource)
3838

3939
public function __toString(): string
4040
{
41-
return $this->resource;
41+
return 'existence.'.$this->resource;
4242
}
4343

4444
public function getResource(): string

src/Symfony/Component/Config/Tests/Resource/FileExistenceResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function tearDown(): void
3636

3737
public function testToString()
3838
{
39-
$this->assertSame($this->file, (string) $this->resource);
39+
$this->assertSame('existence.'.$this->file, (string) $this->resource);
4040
}
4141

4242
public function testGetResource()

src/Symfony/Component/HttpKernel/DataCollector/LoggerDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private function getContainerDeprecationLogs(): array
210210

211211
private function getContainerCompilerLogs(string $compilerLogsFilepath = null): array
212212
{
213-
if (!is_file($compilerLogsFilepath)) {
213+
if (!$compilerLogsFilepath || !is_file($compilerLogsFilepath)) {
214214
return [];
215215
}
216216

src/Symfony/Component/String/AbstractString.php

Lines changed: 4 additions & 1 deletion
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

src/Symfony/Component/String/Tests/AbstractAsciiTestCase.php

Lines changed: 18 additions & 0 deletions
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)