Skip to content

Commit

Permalink
Closes #3508
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 4, 2019
1 parent 753a192 commit b04ac1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
7 changes: 7 additions & 0 deletions ChangeLog-8.0.md
Expand Up @@ -2,6 +2,12 @@

All notable changes of the PHPUnit 8.0 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## [8.0.2] - 2019-MM-DD

### Fixed

* Fixed [#3508](https://github.com/sebastianbergmann/phpunit/pull/3508): `TypeError` in `Fileloader` when trying to load nonexistent file

## [8.0.1] - 2019-02-03

### Fixed
Expand Down Expand Up @@ -37,6 +43,7 @@ All notable changes of the PHPUnit 8.0 release series are documented in this fil
* Implemented [#2762](https://github.com/sebastianbergmann/phpunit/issues/2762): Drop support for PHP 7.1
* Implemented [#3123](https://github.com/sebastianbergmann/phpunit/issues/3123): Remove `PHPUnit_Framework_MockObject_MockObject`

[8.0.2]: https://github.com/sebastianbergmann/phpunit/compare/8.0.1...8.0.2
[8.0.1]: https://github.com/sebastianbergmann/phpunit/compare/8.0.0...8.0.1
[8.0.0]: https://github.com/sebastianbergmann/phpunit/compare/7.5...8.0.0

22 changes: 16 additions & 6 deletions src/Util/FileLoader.php
Expand Up @@ -29,14 +29,16 @@ final class FileLoader
public static function checkAndLoad(string $filename): string
{
$includePathFilename = \stream_resolve_include_path($filename);
$localFile = __DIR__ . \DIRECTORY_SEPARATOR . $filename;

/**
* @see https://github.com/sebastianbergmann/phpunit/pull/2751
*/
$isReadable = @\fopen($includePathFilename, 'r') !== false;
if (!$includePathFilename) {
throw new Exception(
\sprintf('Cannot open file "%s".' . "\n", $filename)
);
}

$localFile = __DIR__ . \DIRECTORY_SEPARATOR . $filename;

if (!$includePathFilename || !$isReadable || $includePathFilename === $localFile) {
if (!self::isReadable($includePathFilename) || $includePathFilename === $localFile) {
throw new Exception(
\sprintf('Cannot open file "%s".' . "\n", $filename)
);
Expand Down Expand Up @@ -65,4 +67,12 @@ public static function load(string $filename): void
}
}
}

/**
* @see https://github.com/sebastianbergmann/phpunit/pull/2751
*/
private static function isReadable(string $filename): bool
{
return @\fopen($filename, 'r') !== false;
}
}

0 comments on commit b04ac1d

Please sign in to comment.