From b856f62cd4443a7ecd780a13a3374a8b3d7f30ae Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Wed, 26 Aug 2015 11:54:34 +0200 Subject: [PATCH] [Translation] Fix the string casting in the XliffFileLoader --- src/Symfony/Component/Translation/Loader/XliffFileLoader.php | 2 +- .../Component/Translation/Tests/Loader/XliffFileLoaderTest.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php index 9f55d90123..6306da672e 100644 --- a/src/Symfony/Component/Translation/Loader/XliffFileLoader.php +++ b/src/Symfony/Component/Translation/Loader/XliffFileLoader.php @@ -53,7 +53,7 @@ class XliffFileLoader implements LoaderInterface } $source = isset($attributes['resname']) && $attributes['resname'] ? $attributes['resname'] : $translation->source; - $target = (string) isset($translation->target) ? $translation->target : $source; + $target = (string) (isset($translation->target) ? $translation->target : $source); // If the xlf file has another encoding specified, try to convert it because // simple_xml will always return utf-8 encoded values diff --git a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php index 15ff655ce6..c1098dee85 100644 --- a/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php +++ b/src/Symfony/Component/Translation/Tests/Loader/XliffFileLoaderTest.php @@ -25,6 +25,7 @@ class XliffFileLoaderTest extends \PHPUnit_Framework_TestCase $this->assertEquals('en', $catalogue->getLocale()); $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); $this->assertSame(array(), libxml_get_errors()); + $this->assertContainsOnly('string', $catalogue->all('domain1')); } public function testLoadWithInternalErrorsEnabled()