From f1370eb56ab7e36fbebf16409ecda9001040c7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 18 Mar 2024 15:41:10 +0100 Subject: [PATCH 1/2] Drop support for Composer 1.x --- CHANGELOG.md | 3 ++- composer.json | 1 + src/Connection.php | 13 ++++--------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a1fe6c95..c03bda1e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,8 +3,9 @@ All notable changes to this project will be documented in this file. ## [unreleased] +* Drop support for Composer 1.x by @GromNaN in [#2784](https://github.com/mongodb/laravel-mongodb/pull/2784) -## [4.2.0] - 2024-12-14 +## [4.2.0] - 2024-03-14 * Add support for Laravel 11 by @GromNaN in [#2735](https://github.com/mongodb/laravel-mongodb/pull/2735) * Implement Model::createOrFirst() using findOneAndUpdate operation by @GromNaN in [#2742](https://github.com/mongodb/laravel-mongodb/pull/2742) diff --git a/composer.json b/composer.json index d19c1149a..d994cda29 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "require": { "php": "^8.1", "ext-mongodb": "^1.15", + "composer-runtime-api": "^2.0.0", "illuminate/support": "^10.0|^11", "illuminate/container": "^10.0|^11", "illuminate/database": "^10.30|^11", diff --git a/src/Connection.php b/src/Connection.php index 3f529cdea..0c1866ce9 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -16,7 +16,6 @@ use MongoDB\Laravel\Concerns\ManagesTransactions; use Throwable; -use function class_exists; use function filter_var; use function implode; use function is_array; @@ -324,14 +323,10 @@ private static function getVersion(): string private static function lookupVersion(): string { - if (class_exists(InstalledVersions::class)) { - try { - return self::$version = InstalledVersions::getPrettyVersion('mongodb/laravel-mongodb'); - } catch (Throwable) { - return self::$version = 'error'; - } + try { + return self::$version = InstalledVersions::getPrettyVersion('mongodb/laravel-mongodb'); + } catch (Throwable) { + return self::$version = 'error'; } - - return self::$version = 'unknown'; } } From a9aa5438f9ed15dd577b364568b374dbfc20afdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 25 Mar 2024 17:24:51 +0100 Subject: [PATCH 2/2] Update src/Connection.php Co-authored-by: Jeremy Mikola --- src/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Connection.php b/src/Connection.php index 0c1866ce9..01232c7ae 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -324,7 +324,7 @@ private static function getVersion(): string private static function lookupVersion(): string { try { - return self::$version = InstalledVersions::getPrettyVersion('mongodb/laravel-mongodb'); + return self::$version = InstalledVersions::getPrettyVersion('mongodb/laravel-mongodb') ?? 'unknown'; } catch (Throwable) { return self::$version = 'error'; }