From efce640a5ef93b147e5f7a984d4454772a2eca80 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Fri, 13 Jan 2012 10:48:50 +0200 Subject: [PATCH 1/2] [Yaml][Parser] throw an exception if not readable --- src/Symfony/Component/Yaml/Yaml.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index aad88fdc19..e9a34ea0c4 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -47,7 +47,14 @@ class Yaml $file = ''; // if input is a file, process it - if (strpos($input, "\n") === false && is_file($input) && is_readable($input)) { + if (strpos($input, "\n") === false && is_file($input)) { + if (false === is_readable($input)) { + throw new \InvalidArgumentException(sprintf( + 'The service file "%s" is not readable.', + $input + )); + } + $file = $input; ob_start(); From 79610141401fd901a886c430ea526315af8ef1f1 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Fri, 13 Jan 2012 17:48:38 +0200 Subject: [PATCH 2/2] [Yaml][Parser] changes according review --- src/Symfony/Component/Yaml/Yaml.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index e9a34ea0c4..a59ce86f48 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -49,10 +49,7 @@ class Yaml // if input is a file, process it if (strpos($input, "\n") === false && is_file($input)) { if (false === is_readable($input)) { - throw new \InvalidArgumentException(sprintf( - 'The service file "%s" is not readable.', - $input - )); + throw new ParseException(sprintf('Unable to parse "%s" as the file is not readable.', $input)); } $file = $input;