aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe-php-shim/src/var.rs9
-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
-rw-r--r--crates/shirabe/tests/downloader/download_manager_test.rs11
17 files changed, 37 insertions, 18 deletions
diff --git a/crates/shirabe-php-shim/src/var.rs b/crates/shirabe-php-shim/src/var.rs
index 257dd8bd..4b0ed2f5 100644
--- a/crates/shirabe-php-shim/src/var.rs
+++ b/crates/shirabe-php-shim/src/var.rs
@@ -230,15 +230,6 @@ pub fn get_class_err(_e: &anyhow::Error) -> String {
todo!()
}
-/// Overload accepting any object reference. PHP's `get_class($obj)` returns the
-/// class name; in Rust we don't have a runtime class name, so this stub is left
-/// as `todo!()`.
-pub fn get_class_obj<T: ?Sized>(_object: &T) -> String {
- // TODO(php-runtime): PHP returns the object's class name; Rust has no runtime class name for an
- // arbitrary `T` (the static type path is not the PHP class name).
- todo!()
-}
-
pub fn get_debug_type(value: &PhpMixed) -> String {
match value {
PhpMixed::Null => "null".to_string(),
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,
diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs
index 9b45d47a..b7d88a21 100644
--- a/crates/shirabe/tests/downloader/download_manager_test.rs
+++ b/crates/shirabe/tests/downloader/download_manager_test.rs
@@ -59,6 +59,10 @@ mockall::mock! {
}
}
+// PHPUnit reports a generated class name for `getMockBuilder(DownloaderInterface::class)`;
+// no ported assertion reads it, so the mock answers with the interface it stands in for.
+shirabe_php_shim::impl_php_class!(MockDownloader, r"Composer\Downloader\DownloaderInterface");
+
/// ref: DownloadManagerTest::createPackageMock
///
/// PHPUnit returns a `PackageInterface` mock; a real CompletePackage with the
@@ -169,10 +173,6 @@ fn test_get_downloader_for_correctly_installed_dist_package() {
assert!(std::rc::Rc::ptr_eq(&downloader, &result));
}
-// The LogicException message uses get_class($downloader); the equivalent
-// `shirabe_php_shim::get_class_obj` is still a `todo!()`, so building the error
-// panics before `getDownloaderForPackage` can return it.
-#[ignore = "requires shirabe_php_shim::get_class_obj (PHP get_class), still todo!()"]
#[test]
fn test_get_downloader_for_incorrectly_installed_dist_package() {
let package = create_package_mock();
@@ -206,9 +206,6 @@ fn test_get_downloader_for_correctly_installed_source_package() {
assert!(std::rc::Rc::ptr_eq(&downloader, &result));
}
-// See test_get_downloader_for_incorrectly_installed_dist_package: the LogicException
-// path depends on the still-unimplemented get_class_obj shim.
-#[ignore = "requires shirabe_php_shim::get_class_obj (PHP get_class), still todo!()"]
#[test]
fn test_get_downloader_for_incorrectly_installed_source_package() {
let package = create_package_mock();