aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/mozart/src/composer.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-10 01:18:44 +0900
committernsfisis <nsfisis@gmail.com>2026-05-10 01:18:44 +0900
commit4caf72463de598ea9b6454f3b7b7332dd0071318 (patch)
tree62f99c8a48e5b21d75ab70bfd374eb67215542c9 /crates/mozart/src/composer.rs
parent8cc1ba8a02c0318b65658f1634de378c780392b9 (diff)
downloadphp-mozart-4caf72463de598ea9b6454f3b7b7332dd0071318.tar.gz
php-mozart-4caf72463de598ea9b6454f3b7b7332dd0071318.tar.zst
php-mozart-4caf72463de598ea9b6454f3b7b7332dd0071318.zip
refactor(package): port RootPackageLoader into RootPackageData::from_raw
Mirrors Composer\Package\Loader\RootPackageLoader::load(): converts the parsed RawPackageData into fully typed RootPackageData with Link objects, defaulted fields, and trait-based accessors. Composer::package() now returns RootPackageData instead of RawPackageData, eliminating the pre-normalised JSON workaround noted in the previous comment.
Diffstat (limited to 'crates/mozart/src/composer.rs')
-rw-r--r--crates/mozart/src/composer.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/mozart/src/composer.rs b/crates/mozart/src/composer.rs
index 337b053..0484344 100644
--- a/crates/mozart/src/composer.rs
+++ b/crates/mozart/src/composer.rs
@@ -16,7 +16,7 @@ use std::path::{Path, PathBuf};
use crate::factory::create_composer;
use mozart_core::composer::{AutoloadGenerator, InstallationManager, Locker, RepositoryManager};
use mozart_core::config::Config;
-use mozart_core::package::RawPackageData;
+use mozart_core::package::RootPackageData;
use mozart_core::repository::download_manager::DownloadManager;
/// Project-level Composer state. Mirrors `Composer\PartialComposer` /
@@ -27,7 +27,7 @@ use mozart_core::repository::download_manager::DownloadManager;
pub struct Composer {
project_dir: PathBuf,
config: Config,
- package: RawPackageData,
+ package: RootPackageData,
repository_manager: RepositoryManager,
installation_manager: InstallationManager,
download_manager: DownloadManager,
@@ -45,7 +45,7 @@ impl Composer {
pub fn new(
project_dir: PathBuf,
config: Config,
- package: RawPackageData,
+ package: RootPackageData,
repository_manager: RepositoryManager,
installation_manager: InstallationManager,
download_manager: DownloadManager,
@@ -111,12 +111,12 @@ impl Composer {
&self.config
}
- /// Root package loaded from the project's `composer.json`. Mirrors
- /// `Composer::getPackage()`; ideally this would return a fully
- /// resolved `RootPackageInterface` equivalent, but Mozart does not
- /// yet have a `RootPackageLoader` port — for now callers see the
- /// raw, pre-normalised JSON shape.
- pub fn package(&self) -> &RawPackageData {
+ /// Root package loaded from the project's `composer.json`.
+ /// Mirrors `Composer::getPackage()` — returns a fully typed
+ /// [`RootPackageData`] that implements the [`RootPackage`] trait
+ /// hierarchy (`Package` → `CompletePackage` → `RootPackage`),
+ /// equivalent to PHP's `RootPackageInterface`.
+ pub fn package(&self) -> &RootPackageData {
&self.package
}