Skip to content

Commit f1cbc70

Browse files
authored
PHPLIB-1302: Use Composer\InstalledVersions (#1262)
There is no impact on Composer requirements since jean85/pretty-package-versions 2.0+ previously required composer-runtime-api 2.0+.
1 parent 755b708 commit f1cbc70

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"ext-hash": "*",
1515
"ext-json": "*",
1616
"ext-mongodb": "^1.18.0",
17-
"jean85/pretty-package-versions": "^2.0.1",
17+
"composer-runtime-api": "^2.0",
1818
"psr/log": "^1.1.4|^2|^3",
1919
"symfony/polyfill-php80": "^1.27",
2020
"symfony/polyfill-php81": "^1.27"

src/Client.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
namespace MongoDB;
1919

20+
use Composer\InstalledVersions;
2021
use Iterator;
21-
use Jean85\PrettyVersions;
2222
use MongoDB\Driver\ClientEncryption;
2323
use MongoDB\Driver\Exception\InvalidArgumentException as DriverInvalidArgumentException;
2424
use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException;
@@ -396,9 +396,9 @@ private static function getVersion(): string
396396
{
397397
if (self::$version === null) {
398398
try {
399-
self::$version = PrettyVersions::getVersion('mongodb/mongodb')->getPrettyVersion();
399+
self::$version = InstalledVersions::getPrettyVersion('mongodb/mongodb') ?? 'unknown';
400400
} catch (Throwable $t) {
401-
return 'unknown';
401+
self::$version = 'error';
402402
}
403403
}
404404

0 commit comments

Comments
 (0)