From fca6b6a5217ebc27a2755a7cb8afe78c2a14a1de Mon Sep 17 00:00:00 2001 From: mkveksas Date: Sun, 3 Feb 2019 15:45:16 +0000 Subject: [PATCH 1/3] fix(file-loader): fix fatal error in FileLoader.php when a file does not exist --- src/Util/FileLoader.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Util/FileLoader.php b/src/Util/FileLoader.php index 817ee70d699..7ce2e05fea1 100644 --- a/src/Util/FileLoader.php +++ b/src/Util/FileLoader.php @@ -32,9 +32,17 @@ public static function checkAndLoad(string $filename): string $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. */ - $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( From aeddd7cd09b93c7614c061e956f68c622b534c34 Mon Sep 17 00:00:00 2001 From: mkveksas Date: Sun, 3 Feb 2019 15:48:17 +0000 Subject: [PATCH 2/3] fix(file-loader): fix fatal error in FileLoader.php when a file does not exist --- src/Util/FileLoader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Util/FileLoader.php b/src/Util/FileLoader.php index 7ce2e05fea1..7cf937f0b68 100644 --- a/src/Util/FileLoader.php +++ b/src/Util/FileLoader.php @@ -33,7 +33,8 @@ public static function checkAndLoad(string $filename): string /** * 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. + * If a boolean is provided as the path paramater, then a fatal TypeError is thrown, without + * describing what file has failed to load. */ if ($includePathFilename !== false) { /** From 14518697b659de9d8dd6e305344273a934e353fa Mon Sep 17 00:00:00 2001 From: mkveksas Date: Sun, 3 Feb 2019 15:50:32 +0000 Subject: [PATCH 3/3] fix(file-loader): fixed comment with php-cs-fixer --- src/Util/FileLoader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Util/FileLoader.php b/src/Util/FileLoader.php index 7cf937f0b68..73a02faba26 100644 --- a/src/Util/FileLoader.php +++ b/src/Util/FileLoader.php @@ -31,8 +31,8 @@ public static function checkAndLoad(string $filename): string $includePathFilename = \stream_resolve_include_path($filename); $localFile = __DIR__ . \DIRECTORY_SEPARATOR . $filename; - /** - * Due to strict_types = 1 declaration, fopen() expects a string as the path parameter. + /* + * 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. */