From d8bae7b25b621830be6c92778512c87bd2269f5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Bogusz?= Date: Fri, 6 Mar 2020 07:16:17 +0100 Subject: [PATCH] Modifications after review --- .../Tests/Fixtures/Util/{test.xml => not_readable.xml} | 0 src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php | 4 ++-- src/Symfony/Component/Config/Util/XmlUtils.php | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/Symfony/Component/Config/Tests/Fixtures/Util/{test.xml => not_readable.xml} (100%) diff --git a/src/Symfony/Component/Config/Tests/Fixtures/Util/test.xml b/src/Symfony/Component/Config/Tests/Fixtures/Util/not_readable.xml similarity index 100% rename from src/Symfony/Component/Config/Tests/Fixtures/Util/test.xml rename to src/Symfony/Component/Config/Tests/Fixtures/Util/not_readable.xml diff --git a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php index e038943d2f3d4..507a5a7cd97e6 100644 --- a/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php +++ b/src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php @@ -38,8 +38,8 @@ public function testLoadFile() if ('\\' === \DIRECTORY_SEPARATOR) { $this->markTestSkipped('chmod is not supported on Windows'); } - chmod($fixtures.'test.xml', 000); - XmlUtils::loadFile($fixtures.'test.xml'); + chmod($fixtures.'not_readable.xml', 000); + XmlUtils::loadFile($fixtures.'not_readable.xml'); $this->fail(); } catch (\InvalidArgumentException $e) { $this->assertStringContainsString('is not readable', $e->getMessage()); diff --git a/src/Symfony/Component/Config/Util/XmlUtils.php b/src/Symfony/Component/Config/Util/XmlUtils.php index dd65f3f61e682..c925f315e5ed3 100644 --- a/src/Symfony/Component/Config/Util/XmlUtils.php +++ b/src/Symfony/Component/Config/Util/XmlUtils.php @@ -123,17 +123,17 @@ public static function parse($content, $schemaOrCallable = null) public static function loadFile($file, $schemaOrCallable = null) { if (!is_file($file)) { - throw new \InvalidArgumentException(sprintf('Resource %s is not a file.', $file)); + throw new \InvalidArgumentException(sprintf('Resource "%s" is not a file.', $file)); } if (!is_readable($file)) { - throw new \InvalidArgumentException(sprintf('File %s is not readable.', $file)); + throw new \InvalidArgumentException(sprintf('File "%s" is not readable.', $file)); } - $content = file_get_contents($file); + $content = @file_get_contents($file); if ('' === trim($content)) { - throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file)); + throw new \InvalidArgumentException(sprintf('File "%s" does not contain valid XML, it is empty.', $file)); } try {