diff --git a/src/Util/FileLoader.php b/src/Util/FileLoader.php index 817ee70d699..73a02faba26 100644 --- a/src/Util/FileLoader.php +++ b/src/Util/FileLoader.php @@ -31,10 +31,19 @@ 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 + /* + * Due to strict_types = 1 declaration, fopen() expects a string as the path parameter. + * If a boolean is provided as the path paramater, then a fatal TypeError is thrown, without + * describing what file has failed to load. */ - $isReadable = @\fopen($includePathFilename, 'r') !== false; + if ($includePathFilename !== false) { + /** + * @see https://github.com/sebastianbergmann/phpunit/pull/2751 + */ + $isReadable = @\fopen($includePathFilename, 'r') !== false; + } else { + $isReadable = false; + } if (!$includePathFilename || !$isReadable || $includePathFilename === $localFile) { throw new Exception(