Skip to content

Commit

Permalink
Merge branch '9.6' into 10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed May 31, 2023
2 parents fb20bac + 284eedd commit 634cd30
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Runner/Extension/PharLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
*/
namespace PHPUnit\Runner\Extension;

use function count;
use function explode;
use function extension_loaded;
use function implode;
use function is_file;
use function str_contains;
use PharIo\Manifest\ApplicationName;
use PharIo\Manifest\Exception as ManifestException;
use PharIo\Manifest\ManifestLoader;
Expand Down Expand Up @@ -56,7 +60,7 @@ public function loadPharExtensionsInDirectory(string $directory): array

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

if (!$manifest->isExtensionFor($applicationName)) {
Expand Down Expand Up @@ -99,4 +103,21 @@ public function loadPharExtensionsInDirectory(string $directory): array
'notLoadedExtensions' => $notLoadedExtensions,
];
}

private function phpunitVersion(): string
{
$version = Version::id();

if (!str_contains($version, '-')) {
return $version;
}

$parts = explode('.', explode('-', $version)[0]);

if (count($parts) === 2) {
$parts[] = 0;
}

return implode('.', $parts);
}
}

0 comments on commit 634cd30

Please sign in to comment.