diff --git a/.psalm/baseline.xml b/.psalm/baseline.xml
index dad958ea910..1a9adc5df44 100644
--- a/.psalm/baseline.xml
+++ b/.psalm/baseline.xml
@@ -724,6 +724,8 @@
+
+
diff --git a/src/Runner/PhptTestCase.php b/src/Runner/PhptTestCase.php
index a5840f052b0..993a3b8e439 100644
--- a/src/Runner/PhptTestCase.php
+++ b/src/Runner/PhptTestCase.php
@@ -638,7 +638,11 @@ private function cleanupForCoverage(): RawCodeCoverageData
$coverage = RawCodeCoverageData::fromXdebugWithoutPathCoverage([]);
$files = $this->getCoverageFiles();
- $buffer = @file_get_contents($files['coverage']);
+ $buffer = false;
+
+ if (is_file($files['coverage'])) {
+ $buffer = @file_get_contents($files['coverage']);
+ }
if ($buffer !== false) {
$coverage = @unserialize($buffer);
diff --git a/src/Runner/ResultCache/DefaultResultCache.php b/src/Runner/ResultCache/DefaultResultCache.php
index 090935f98f9..965fce956fe 100644
--- a/src/Runner/ResultCache/DefaultResultCache.php
+++ b/src/Runner/ResultCache/DefaultResultCache.php
@@ -17,6 +17,7 @@
use function file_put_contents;
use function is_array;
use function is_dir;
+use function is_file;
use function json_decode;
use function json_encode;
use PHPUnit\Framework\TestStatus\TestStatus;
@@ -85,7 +86,11 @@ public function time(string $id): float
public function load(): void
{
- $contents = @file_get_contents($this->cacheFilename);
+ if (!is_file($this->cacheFilename)) {
+ return;
+ }
+
+ $contents = file_get_contents($this->cacheFilename);
if ($contents === false) {
return;
diff --git a/src/TextUI/Application.php b/src/TextUI/Application.php
index 9f1bd1c28b3..d95541e19e2 100644
--- a/src/TextUI/Application.php
+++ b/src/TextUI/Application.php
@@ -10,6 +10,7 @@
namespace PHPUnit\TextUI;
use const PHP_EOL;
+use function is_file;
use function is_readable;
use function printf;
use function realpath;
@@ -509,7 +510,9 @@ private function writeRandomSeedInformation(Printer $printer, Configuration $con
private function registerLogfileWriters(Configuration $configuration): void
{
if ($configuration->hasLogEventsText()) {
- @unlink($configuration->logEventsText());
+ if (is_file($configuration->logEventsText())) {
+ unlink($configuration->logEventsText());
+ }
EventFacade::instance()->registerTracer(
new EventLogger(
@@ -520,7 +523,9 @@ private function registerLogfileWriters(Configuration $configuration): void
}
if ($configuration->hasLogEventsVerboseText()) {
- @unlink($configuration->logEventsVerboseText());
+ if (is_file($configuration->logEventsVerboseText())) {
+ unlink($configuration->logEventsVerboseText());
+ }
EventFacade::instance()->registerTracer(
new EventLogger(
diff --git a/src/Util/PHP/AbstractPhpProcess.php b/src/Util/PHP/AbstractPhpProcess.php
index b6bee780518..221508057a6 100644
--- a/src/Util/PHP/AbstractPhpProcess.php
+++ b/src/Util/PHP/AbstractPhpProcess.php
@@ -14,6 +14,7 @@
use function array_merge;
use function assert;
use function escapeshellarg;
+use function file_exists;
use function file_get_contents;
use function ini_get_all;
use function restore_error_handler;
@@ -136,13 +137,12 @@ public function runTestJob(string $job, Test $test, string $processResultFile):
{
$_result = $this->runJob($job);
- $processResult = @file_get_contents($processResultFile);
+ $processResult = '';
- if ($processResult !== false) {
+ if (file_exists($processResultFile)) {
+ $processResult = file_get_contents($processResultFile);
@unlink($processResultFile);
- } else {
- $processResult = '';
}
$this->processChildResult(
diff --git a/tests/end-to-end/regression/5764/5764.phpt b/tests/end-to-end/regression/5764/5764.phpt
new file mode 100644
index 00000000000..5c56917a27e
--- /dev/null
+++ b/tests/end-to-end/regression/5764/5764.phpt
@@ -0,0 +1,21 @@
+--TEST--
+https://github.com/sebastianbergmann/phpunit/issues/5764
+--FILE--
+run($_SERVER['argv']);
+--EXPECTF--
+PHPUnit %s by Sebastian Bergmann and contributors.
+
+Runtime: %s
+Configuration: %s
+
+There was 1 PHPUnit test runner warning:
+
+1) No tests found in class "PHPUnit\TestFixture\Issue5764\Issue5764Test".
+
+No tests executed!
diff --git a/tests/end-to-end/regression/5764/error-handler.php b/tests/end-to-end/regression/5764/error-handler.php
new file mode 100644
index 00000000000..0c245d77722
--- /dev/null
+++ b/tests/end-to-end/regression/5764/error-handler.php
@@ -0,0 +1,13 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+\set_error_handler(static function (int $err_lvl, string $err_msg, string $err_file, int $err_line): bool
+{
+ throw new ErrorException($err_msg, 0, $err_lvl, $err_file, $err_line);
+});
diff --git a/tests/end-to-end/regression/5764/phpunit.xml b/tests/end-to-end/regression/5764/phpunit.xml
new file mode 100644
index 00000000000..e3f2c4b08fd
--- /dev/null
+++ b/tests/end-to-end/regression/5764/phpunit.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ tests
+
+
+
diff --git a/tests/end-to-end/regression/5764/tests/Issue5764Test.php b/tests/end-to-end/regression/5764/tests/Issue5764Test.php
new file mode 100644
index 00000000000..c1d2614fd43
--- /dev/null
+++ b/tests/end-to-end/regression/5764/tests/Issue5764Test.php
@@ -0,0 +1,16 @@
+
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+namespace PHPUnit\TestFixture\Issue5764;
+
+use PHPUnit\Framework\TestCase;
+
+final class Issue5764Test extends TestCase
+{
+}