From d14b3b575eefbd1731b5777f371888da1d0347ca Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 23 Dec 2021 12:10:40 +0100 Subject: [PATCH] Fix GlobalState collection to ignore the Composer proxy --- src/Util/GlobalState.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Util/GlobalState.php b/src/Util/GlobalState.php index 0bd52de25ef..6577faf89e6 100644 --- a/src/Util/GlobalState.php +++ b/src/Util/GlobalState.php @@ -67,7 +67,14 @@ public static function processIncludedFilesAsString(array $files): string $prefix = 'phar://' . __PHPUNIT_PHAR__ . '/'; } - for ($i = count($files) - 1; $i > 0; $i--) { + // Do not process bootstrap script + array_shift($files); + // If bootstrap script was a Composer bin proxy, skip the second entry as well + if (substr(strtr($files[0], '\\', '/'), -24) === '/phpunit/phpunit/phpunit') { + array_shift($files); + } + + for ($i = count($files) - 1; $i >= 0; $i--) { $file = $files[$i]; if (!empty($GLOBALS['__PHPUNIT_ISOLATION_BLACKLIST']) &&