|
@@ -122,18 +122,25 @@ class ClassMapGenerator
|
|
|
$extraTypes .= '|enum';
|
|
|
}
|
|
|
|
|
|
- try {
|
|
|
- $contents = Silencer::call('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');
|
|
|
- }
|
|
|
+ // Use @ here instead of Silencer to actively suppress 'unhelpful' output
|
|
|
+ // @link https://github.com/composer/composer/pull/4886
|
|
|
+ $contents = @php_strip_whitespace($path);
|
|
|
+ if (!$contents) {
|
|
|
+ if (!file_exists($path)) {
|
|
|
+ $message = 'File at "%s" does not exist, check your classmap definitions';
|
|
|
+ } elseif (!is_readable($path)) {
|
|
|
+ $message = 'File at "%s" is not readable, check its permissions';
|
|
|
+ } elseif ('' === trim(file_get_contents($path))) {
|
|
|
+ // The input file was really empty and thus contains no classes
|
|
|
+ return array();
|
|
|
+ } else {
|
|
|
+ $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
|
|
|
+ }
|
|
|
+ $error = error_get_last();
|
|
|
+ if (isset($error['message'])) {
|
|
|
+ $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
|
|
|
}
|
|
|
- } catch (\Exception $e) {
|
|
|
- throw new \RuntimeException('Could not scan for classes inside '.$path.": \n".$e->getMessage(), 0, $e);
|
|
|
+ throw new \RuntimeException(sprintf($message, $path));
|
|
|
}
|
|
|
|
|
|
// return early if there is no chance of matching anything in this file
|