From c2d99608988e7892a4c67f0c57c0fdb68de2d4b1 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Sat, 6 Feb 2016 02:00:54 +0100 Subject: [PATCH] Ensure exception is thrown when classmaps are requested for corrupted or binary files. Refs #4885 --- src/Composer/Autoload/ClassMapGenerator.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Composer/Autoload/ClassMapGenerator.php b/src/Composer/Autoload/ClassMapGenerator.php index 3f1243ade..539eb77a0 100644 --- a/src/Composer/Autoload/ClassMapGenerator.php +++ b/src/Composer/Autoload/ClassMapGenerator.php @@ -123,14 +123,14 @@ class ClassMapGenerator } try { - $contents = Silencer::call('php_strip_whitespace', $path); + $contents = @php_strip_whitespace($path); if (!$contents) { if (!file_exists($path)) { - throw new \Exception('File does not exist'); - } - if (!is_readable($path)) { - throw new \Exception('File is not readable'); + throw new \RuntimeException(sprintf('File at "%s" does not exist, check your classmap definitions', $path)); + } elseif (!is_readable($path)) { + throw new \RuntimeException(sprintf('File at "%s" is not readable, check its permissions', $path)); } + throw new \RuntimeException(sprintf('File at "%s" could not be parsed as PHP - it may be binary or corrupted', $path)); } } catch (\Exception $e) { throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);