1
0
Fork 0

Can't use error_clear_last as it was introduced in PHP7.

pull/4886/head
Niels Keurentjes 2016-02-06 02:58:36 +01:00
parent 6a53b1df42
commit 0b55a0ca91
2 changed files with 6 additions and 7 deletions

View File

@ -124,20 +124,19 @@ class ClassMapGenerator
// Use @ here instead of Silencer to actively suppress 'unhelpful' output // Use @ here instead of Silencer to actively suppress 'unhelpful' output
// @link https://github.com/composer/composer/pull/4886 // @link https://github.com/composer/composer/pull/4886
error_clear_last();
$contents = @php_strip_whitespace($path); $contents = @php_strip_whitespace($path);
if (!$contents) { if (!$contents) {
$error = error_get_last(); if (!file_exists($path)) {
if (is_null($error)) {
// No error, so the input file was really empty and thus contains no classes
return array();
} elseif (!file_exists($path)) {
$message = 'File at "%s" does not exist, check your classmap definitions'; $message = 'File at "%s" does not exist, check your classmap definitions';
} elseif (!is_readable($path)) { } elseif (!is_readable($path)) {
$message = 'File at "%s" is not readable, check its permissions'; $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 { } else {
$message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted'; $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
} }
$error = error_get_last();
if (isset($error['message'])) { if (isset($error['message'])) {
$message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message']; $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
} }

View File

@ -113,7 +113,7 @@ class ClassMapGeneratorTest extends TestCase
/** /**
* @expectedException \RuntimeException * @expectedException \RuntimeException
* @expectedExceptionMessage Could not scan for classes inside * @expectedExceptionMessage does not exist
*/ */
public function testFindClassesThrowsWhenFileDoesNotExist() public function testFindClassesThrowsWhenFileDoesNotExist()
{ {