Skip to content

Commit 7b22e98

Browse files
Merge branch '10.1'
2 parents e9e6afb + 634cd30 commit 7b22e98

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/Runner/Extension/PharLoader.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@
99
*/
1010
namespace PHPUnit\Runner\Extension;
1111

12+
use function count;
13+
use function explode;
1214
use function extension_loaded;
15+
use function implode;
1316
use function is_file;
17+
use function str_contains;
1418
use PharIo\Manifest\ApplicationName;
1519
use PharIo\Manifest\Exception as ManifestException;
1620
use PharIo\Manifest\ManifestLoader;
@@ -56,7 +60,7 @@ public function loadPharExtensionsInDirectory(string $directory): array
5660

5761
try {
5862
$applicationName = new ApplicationName('phpunit/phpunit');
59-
$version = new PharIoVersion(Version::series());
63+
$version = new PharIoVersion($this->phpunitVersion());
6064
$manifest = ManifestLoader::fromFile('phar://' . $file . '/manifest.xml');
6165

6266
if (!$manifest->isExtensionFor($applicationName)) {
@@ -99,4 +103,21 @@ public function loadPharExtensionsInDirectory(string $directory): array
99103
'notLoadedExtensions' => $notLoadedExtensions,
100104
];
101105
}
106+
107+
private function phpunitVersion(): string
108+
{
109+
$version = Version::id();
110+
111+
if (!str_contains($version, '-')) {
112+
return $version;
113+
}
114+
115+
$parts = explode('.', explode('-', $version)[0]);
116+
117+
if (count($parts) === 2) {
118+
$parts[] = 0;
119+
}
120+
121+
return implode('.', $parts);
122+
}
102123
}

0 commit comments

Comments
 (0)