1
0
Fork 0

Further reorganized messy checking code.

pull/4886/head
Niels Keurentjes 2016-02-06 02:40:16 +01:00
parent bb08f76ad9
commit 6a53b1df42
1 changed files with 11 additions and 5 deletions

View File

@ -127,15 +127,21 @@ class ClassMapGenerator
error_clear_last(); error_clear_last();
$contents = @php_strip_whitespace($path); $contents = @php_strip_whitespace($path);
if (!$contents) { if (!$contents) {
if (is_null(error_get_last())) { $error = error_get_last();
// No error, so the input file was really empty or contained only comments if (is_null($error)) {
// No error, so the input file was really empty and thus contains no classes
return array(); return array();
} elseif (!file_exists($path)) { } elseif (!file_exists($path)) {
throw new \RuntimeException(sprintf('File at "%s" does not exist, check your classmap definitions', $path)); $message = 'File at "%s" does not exist, check your classmap definitions';
} elseif (!is_readable($path)) { } elseif (!is_readable($path)) {
throw new \RuntimeException(sprintf('File at "%s" is not readable, check its permissions', $path)); $message = 'File at "%s" is not readable, check its permissions';
} else {
$message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
} }
throw new \RuntimeException(sprintf('File at "%s" could not be parsed as PHP - it may be binary or corrupted', $path)); if (isset($error['message'])) {
$message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
}
throw new \RuntimeException(sprintf($message, $path));
} }
// return early if there is no chance of matching anything in this file // return early if there is no chance of matching anything in this file