aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/downloader
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-06 20:38:00 +0900
committernsfisis <nsfisis@gmail.com>2026-08-06 20:38:00 +0900
commit9411867aa23f8f4f3a6b21b4e8ca9f498a16283a (patch)
tree1d679d8fa48fcae87b036a00301c9fba0d210b3f /crates/shirabe/src/downloader
parentf18efec69df00cf61e3ec595d07131cae7ca0372 (diff)
downloadphp-shirabe-9411867aa23f8f4f3a6b21b4e8ca9f498a16283a.tar.gz
php-shirabe-9411867aa23f8f4f3a6b21b4e8ca9f498a16283a.tar.zst
php-shirabe-9411867aa23f8f4f3a6b21b4e8ca9f498a16283a.zip
fix(download-manager): name the downloader class in its LogicException
getDownloaderForPackage reports get_class($downloader) when the resolved downloader's installation source does not match. Rust has no runtime class name, so the message was built from a shim stub that panicked instead — the error could never be returned. DownloaderInterface now requires PhpClass, the trait already used for the same purpose on Command, and each downloader states the name PHP reports. That leaves get_class_obj without callers, so it is gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/downloader')
-rw-r--r--crates/shirabe/src/downloader/download_manager.rs2
-rw-r--r--crates/shirabe/src/downloader/downloader_interface.rs4
-rw-r--r--crates/shirabe/src/downloader/file_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/fossil_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/git_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/gzip_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/hg_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/path_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/perforce_downloader.rs5
-rw-r--r--crates/shirabe/src/downloader/phar_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/rar_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/svn_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/tar_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/xz_downloader.rs2
-rw-r--r--crates/shirabe/src/downloader/zip_downloader.rs2
15 files changed, 33 insertions, 2 deletions
diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs
index 7ff21a25..682fdcb8 100644
--- a/crates/shirabe/src/downloader/download_manager.rs
+++ b/crates/shirabe/src/downloader/download_manager.rs
@@ -149,7 +149,7 @@ impl DownloadManager {
return Err(LogicException {
message: format!(
"Downloader \"{}\" is a {} type downloader and can not be used to download {} for package {}",
- shirabe_php_shim::get_class_obj(&*downloader.borrow()),
+ shirabe_php_shim::PhpClass::php_class_name(&*downloader.borrow()),
downloader_installation_source,
installation_source.unwrap_or_default(),
package,
diff --git a/crates/shirabe/src/downloader/downloader_interface.rs b/crates/shirabe/src/downloader/downloader_interface.rs
index 873438e2..8f2e2c0d 100644
--- a/crates/shirabe/src/downloader/downloader_interface.rs
+++ b/crates/shirabe/src/downloader/downloader_interface.rs
@@ -3,8 +3,10 @@
use crate::package::PackageInterfaceHandle;
use shirabe_php_shim::PhpMixed;
+/// `PhpClass` is a supertrait because `DownloadManager::getDownloaderForPackage` reports
+/// `get_class($downloader)` in its error message, and Rust has no runtime class name.
#[async_trait::async_trait(?Send)]
-pub trait DownloaderInterface: std::fmt::Debug {
+pub trait DownloaderInterface: std::fmt::Debug + shirabe_php_shim::PhpClass {
fn get_installation_source(&self) -> String;
async fn download(
diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs
index 4ee580f8..053a7161 100644
--- a/crates/shirabe/src/downloader/file_downloader.rs
+++ b/crates/shirabe/src/downloader/file_downloader.rs
@@ -47,6 +47,8 @@ pub static DOWNLOAD_METADATA: LazyLock<Mutex<IndexMap<String, PhpMixed>>> =
pub static RESPONSE_HEADERS: LazyLock<Mutex<IndexMap<String, Vec<String>>>> =
LazyLock::new(|| Mutex::new(IndexMap::new()));
+shirabe_php_shim::impl_php_class!(FileDownloader, r"Composer\Downloader\FileDownloader");
+
/// Base downloader for files
#[derive(Debug)]
pub struct FileDownloader {
diff --git a/crates/shirabe/src/downloader/fossil_downloader.rs b/crates/shirabe/src/downloader/fossil_downloader.rs
index 2f6df9a4..c6be8f24 100644
--- a/crates/shirabe/src/downloader/fossil_downloader.rs
+++ b/crates/shirabe/src/downloader/fossil_downloader.rs
@@ -15,6 +15,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{PhpMixed, RuntimeException, php_regex};
+shirabe_php_shim::impl_php_class!(FossilDownloader, r"Composer\Downloader\FossilDownloader");
+
#[derive(Debug)]
pub struct FossilDownloader {
inner: VcsDownloaderBase,
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs
index 0becf427..dd5f4e41 100644
--- a/crates/shirabe/src/downloader/git_downloader.rs
+++ b/crates/shirabe/src/downloader/git_downloader.rs
@@ -23,6 +23,8 @@ use shirabe_php_shim::{
php_regex, preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare,
};
+shirabe_php_shim::impl_php_class!(GitDownloader, r"Composer\Downloader\GitDownloader");
+
#[derive(Debug)]
pub struct GitDownloader {
inner: VcsDownloaderBase,
diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs
index 297cbc11..ff7962e0 100644
--- a/crates/shirabe/src/downloader/gzip_downloader.rs
+++ b/crates/shirabe/src/downloader/gzip_downloader.rs
@@ -19,6 +19,8 @@ use shirabe_php_shim::{
strtr,
};
+shirabe_php_shim::impl_php_class!(GzipDownloader, r"Composer\Downloader\GzipDownloader");
+
#[derive(Debug)]
pub struct GzipDownloader {
inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/hg_downloader.rs b/crates/shirabe/src/downloader/hg_downloader.rs
index 1feecd3e..68a84535 100644
--- a/crates/shirabe/src/downloader/hg_downloader.rs
+++ b/crates/shirabe/src/downloader/hg_downloader.rs
@@ -15,6 +15,8 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{PhpMixed, RuntimeException};
+shirabe_php_shim::impl_php_class!(HgDownloader, r"Composer\Downloader\HgDownloader");
+
#[derive(Debug)]
pub struct HgDownloader {
inner: VcsDownloaderBase,
diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs
index 72b77fc1..ec07d057 100644
--- a/crates/shirabe/src/downloader/path_downloader.rs
+++ b/crates/shirabe/src/downloader/path_downloader.rs
@@ -27,6 +27,8 @@ use shirabe_php_shim::{
RuntimeException, file_exists, function_exists, is_dir, realpath,
};
+shirabe_php_shim::impl_php_class!(PathDownloader, r"Composer\Downloader\PathDownloader");
+
#[derive(Debug)]
pub struct PathDownloader {
pub(crate) inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/perforce_downloader.rs b/crates/shirabe/src/downloader/perforce_downloader.rs
index 5f272fd5..74b2155b 100644
--- a/crates/shirabe/src/downloader/perforce_downloader.rs
+++ b/crates/shirabe/src/downloader/perforce_downloader.rs
@@ -17,6 +17,11 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
+shirabe_php_shim::impl_php_class!(
+ PerforceDownloader,
+ r"Composer\Downloader\PerforceDownloader"
+);
+
#[derive(Debug)]
pub struct PerforceDownloader {
inner: VcsDownloaderBase,
diff --git a/crates/shirabe/src/downloader/phar_downloader.rs b/crates/shirabe/src/downloader/phar_downloader.rs
index 795d0645..50b45eba 100644
--- a/crates/shirabe/src/downloader/phar_downloader.rs
+++ b/crates/shirabe/src/downloader/phar_downloader.rs
@@ -15,6 +15,8 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{Phar, PhpMixed};
+shirabe_php_shim::impl_php_class!(PharDownloader, r"Composer\Downloader\PharDownloader");
+
#[derive(Debug)]
pub struct PharDownloader {
inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/rar_downloader.rs b/crates/shirabe/src/downloader/rar_downloader.rs
index 39ffc23b..645a5247 100644
--- a/crates/shirabe/src/downloader/rar_downloader.rs
+++ b/crates/shirabe/src/downloader/rar_downloader.rs
@@ -18,6 +18,8 @@ use shirabe_php_shim::{
PhpMixed, RarArchive, RuntimeException, UnexpectedValueException, class_exists, implode,
};
+shirabe_php_shim::impl_php_class!(RarDownloader, r"Composer\Downloader\RarDownloader");
+
#[derive(Debug)]
pub struct RarDownloader {
inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs
index f5b7a833..6abe3ddf 100644
--- a/crates/shirabe/src/downloader/svn_downloader.rs
+++ b/crates/shirabe/src/downloader/svn_downloader.rs
@@ -18,6 +18,8 @@ use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{PhpMixed, RuntimeException, is_dir, php_regex, version_compare};
+shirabe_php_shim::impl_php_class!(SvnDownloader, r"Composer\Downloader\SvnDownloader");
+
#[derive(Debug)]
pub struct SvnDownloader {
inner: VcsDownloaderBase,
diff --git a/crates/shirabe/src/downloader/tar_downloader.rs b/crates/shirabe/src/downloader/tar_downloader.rs
index 3c73595b..ad18f052 100644
--- a/crates/shirabe/src/downloader/tar_downloader.rs
+++ b/crates/shirabe/src/downloader/tar_downloader.rs
@@ -15,6 +15,8 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_php_shim::{PharData, PhpMixed};
+shirabe_php_shim::impl_php_class!(TarDownloader, r"Composer\Downloader\TarDownloader");
+
#[derive(Debug)]
pub struct TarDownloader {
inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/xz_downloader.rs b/crates/shirabe/src/downloader/xz_downloader.rs
index 2041c356..6be5ea2e 100644
--- a/crates/shirabe/src/downloader/xz_downloader.rs
+++ b/crates/shirabe/src/downloader/xz_downloader.rs
@@ -15,6 +15,8 @@ use anyhow::bail;
use indexmap::IndexMap;
use shirabe_php_shim::PhpMixed;
+shirabe_php_shim::impl_php_class!(XzDownloader, r"Composer\Downloader\XzDownloader");
+
#[derive(Debug)]
pub struct XzDownloader {
inner: FileDownloader,
diff --git a/crates/shirabe/src/downloader/zip_downloader.rs b/crates/shirabe/src/downloader/zip_downloader.rs
index d8f7d05e..9d7dbe7a 100644
--- a/crates/shirabe/src/downloader/zip_downloader.rs
+++ b/crates/shirabe/src/downloader/zip_downloader.rs
@@ -22,6 +22,8 @@ static UNZIP_COMMANDS: Mutex<Option<Vec<Vec<String>>>> = Mutex::new(None);
static HAS_ZIP_ARCHIVE: Mutex<Option<bool>> = Mutex::new(None);
static IS_WINDOWS: Mutex<Option<bool>> = Mutex::new(None);
+shirabe_php_shim::impl_php_class!(ZipDownloader, r"Composer\Downloader\ZipDownloader");
+
#[derive(Debug)]
pub struct ZipDownloader {
inner: FileDownloader,