Skip to content

Commit b5ed621

Browse files
authored
Require Composer v2 (#2782)
1 parent 5196c91 commit b5ed621

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

UPGRADE-3.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# UPGRADE FROM 2.x to 3.0
22

3+
## Composer
4+
5+
Composer version 1 is no longer supported. Please upgrade to Composer 2.
6+
37
## Aggregation
48

59
The new `Doctrine\ODM\MongoDB\Aggregation\Builder::getAggregation()` method

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"require": {
2424
"php": "^8.1",
2525
"ext-mongodb": "^1.21 || ^2.0",
26+
"composer-runtime-api": "^2.0",
2627
"doctrine/cache": "^1.11 || ^2.0",
2728
"doctrine/collections": "^1.5 || ^2.0",
2829
"doctrine/event-manager": "^1.0 || ^2.0",
2930
"doctrine/instantiator": "^1.1 || ^2",
3031
"doctrine/persistence": "^3.2 || ^4",
3132
"friendsofphp/proxy-manager-lts": "^1.0",
32-
"jean85/pretty-package-versions": "^1.3.0 || ^2.0.1",
3333
"mongodb/mongodb": "^1.21 || ^2.0@dev",
3434
"psr/cache": "^1.0 || ^2.0 || ^3.0",
3535
"symfony/console": "^5.4 || ^6.0 || ^7.0",

lib/Doctrine/ODM/MongoDB/DocumentManager.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Doctrine\ODM\MongoDB;
66

7+
use Composer\InstalledVersions;
78
use Doctrine\Common\EventManager;
89
use Doctrine\ODM\MongoDB\Hydrator\HydratorFactory;
910
use Doctrine\ODM\MongoDB\Mapping\ClassMetadata;
@@ -25,7 +26,6 @@
2526
use Doctrine\Persistence\ObjectManager;
2627
use Doctrine\Persistence\ObjectRepository;
2728
use InvalidArgumentException;
28-
use Jean85\PrettyVersions;
2929
use MongoDB\Client;
3030
use MongoDB\Collection;
3131
use MongoDB\Database;
@@ -926,14 +926,10 @@ public function getClassNameForAssociation(array $mapping, $data): string
926926

927927
private static function getVersion(): string
928928
{
929-
if (self::$version === null) {
930-
try {
931-
self::$version = PrettyVersions::getVersion('doctrine/mongodb-odm')->getPrettyVersion();
932-
} catch (Throwable) {
933-
return 'unknown';
934-
}
929+
try {
930+
return self::$version ??= InstalledVersions::getPrettyVersion('doctrine/mongodb-odm') ?? 'unknown';
931+
} catch (Throwable) {
932+
return 'error';
935933
}
936-
937-
return self::$version;
938934
}
939935
}

0 commit comments

Comments
 (0)