From 3a388b98a9aa6a14b1c7f7dc909c109cf9837800 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 00:59:54 +0900 Subject: refactor: narrow pub(crate) items to private Porting mapped every PHP `protected` member onto `pub(crate)`, which is wider than nearly all of them need. Each item demoted here is reached only from the module that defines it, so the crate-wide visibility conveyed nothing. Every `pub(crate)` that survives has at least one reader in another module of the same crate. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/downloader/download_manager.rs | 7 ++----- crates/shirabe/src/downloader/file_downloader.rs | 6 +++--- crates/shirabe/src/downloader/git_downloader.rs | 16 ++++++++-------- crates/shirabe/src/downloader/path_downloader.rs | 4 ++-- crates/shirabe/src/downloader/perforce_downloader.rs | 2 +- crates/shirabe/src/downloader/svn_downloader.rs | 6 +++--- crates/shirabe/src/downloader/transport_exception.rs | 8 ++++---- 7 files changed, 23 insertions(+), 26 deletions(-) (limited to 'crates/shirabe/src/downloader') diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index c8fb86a7..15b009e6 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -20,7 +20,7 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct DownloadManager { /// @var IOInterface - pub(crate) io: std::rc::Rc>, + io: std::rc::Rc>, /// @var bool prefer_dist: bool, /// @var bool @@ -425,10 +425,7 @@ impl DownloadManager { /// Determines the install preference of a package /// /// @param PackageInterface $package package instance - pub(crate) fn resolve_package_install_preference( - &self, - package: PackageInterfaceHandle, - ) -> String { + fn resolve_package_install_preference(&self, package: PackageInterfaceHandle) -> String { for (pattern, preference) in &self.package_preferences { let pattern_regex = format!( "{{^{}$}}i", diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index ab9c3672..64b348e1 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -59,13 +59,13 @@ pub struct FileDownloader { /// @var Config pub(crate) config: std::rc::Rc>, /// @var HttpDownloader - pub(crate) http_downloader: std::rc::Rc>, + http_downloader: std::rc::Rc>, /// @var Filesystem pub(crate) filesystem: std::rc::Rc>, /// @var ?Cache - pub(crate) cache: Option>>, + cache: Option>>, /// @var ?EventDispatcher - pub(crate) event_dispatcher: Option>>, + event_dispatcher: Option>>, /// @var ProcessExecutor pub(crate) process: std::rc::Rc>, /// @var array Map of package name to cache key diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index 9e468a44..4394cc95 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -249,7 +249,7 @@ impl GitDownloader { /// /// @throws \RuntimeException /// @return null|string if a string is returned, it is the commit reference that was checked out if the original could not be found - pub(crate) fn update_to_commit( + fn update_to_commit( &self, package: PackageInterfaceHandle, path: &str, @@ -486,7 +486,7 @@ impl GitDownloader { .into()) } - pub(crate) fn update_origin_url(&self, path: &str, url: &str) { + fn update_origin_url(&self, path: &str, url: &str) { let mut output = String::new(); self.inner.process.borrow_mut().execute_args( &[ @@ -503,7 +503,7 @@ impl GitDownloader { self.set_push_url(path, url); } - pub(crate) fn set_push_url(&self, path: &str, url: &str) { + fn set_push_url(&self, path: &str, url: &str) { // set push url for github projects let mut match_: IndexMap = IndexMap::new(); if Preg::is_match3( @@ -549,7 +549,7 @@ impl GitDownloader { } /// @throws \RuntimeException - pub(crate) async fn discard_changes(&self, path: &str) -> anyhow::Result> { + async fn discard_changes(&self, path: &str) -> anyhow::Result> { let path = self.normalize_path(path); let mut output = String::new(); if self.inner.process.borrow_mut().execute_args( @@ -580,7 +580,7 @@ impl GitDownloader { } /// @throws \RuntimeException - pub(crate) async fn stash_changes(&self, path: &str) -> anyhow::Result> { + async fn stash_changes(&self, path: &str) -> anyhow::Result> { let path = self.normalize_path(path); let mut output = String::new(); if self.inner.process.borrow_mut().execute_args( @@ -604,7 +604,7 @@ impl GitDownloader { } /// @throws \RuntimeException - pub(crate) fn view_diff(&self, path: &str) -> anyhow::Result<()> { + fn view_diff(&self, path: &str) -> anyhow::Result<()> { let path = self.normalize_path(path); let mut output = String::new(); if self.inner.process.borrow_mut().execute_args( @@ -625,7 +625,7 @@ impl GitDownloader { Ok(()) } - pub(crate) fn normalize_path(&self, path: &str) -> String { + fn normalize_path(&self, path: &str) -> String { let mut path = path.to_string(); if Platform::is_windows() && strlen(&path) > 0 { let mut base_path = path.clone(); @@ -655,7 +655,7 @@ impl GitDownloader { path } - pub(crate) fn get_short_hash(&self, reference: &str) -> String { + fn get_short_hash(&self, reference: &str) -> String { if !self.inner.io.is_verbose() && Preg::is_match(php_regex!(r"{^[0-9a-f]{40}$}"), reference) { return substr(reference, 0, Some(10)); diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 44940fef..6b3531f4 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -28,7 +28,7 @@ use shirabe_symfony_filesystem::Filesystem as SymfonyFilesystem; #[derive(Debug)] pub struct PathDownloader { - pub(crate) inner: FileDownloader, + inner: FileDownloader, } impl_php_class!(PathDownloader, r"Composer\Downloader\PathDownloader"); @@ -79,7 +79,7 @@ impl PathDownloader { None } - pub(crate) fn get_install_operation_appendix( + fn get_install_operation_appendix( &self, package: PackageInterfaceHandle, path: &str, diff --git a/crates/shirabe/src/downloader/perforce_downloader.rs b/crates/shirabe/src/downloader/perforce_downloader.rs index 9d4ff2a3..f61660be 100644 --- a/crates/shirabe/src/downloader/perforce_downloader.rs +++ b/crates/shirabe/src/downloader/perforce_downloader.rs @@ -20,7 +20,7 @@ use shirabe_php_shim::{PhpMixed, impl_php_class}; #[derive(Debug)] pub struct PerforceDownloader { inner: VcsDownloaderBase, - pub(crate) perforce: std::cell::RefCell>>, + perforce: std::cell::RefCell>>, } impl_php_class!( diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 59916aa2..1487a710 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -23,7 +23,7 @@ use shirabe_php_shim::{ #[derive(Debug)] pub struct SvnDownloader { inner: VcsDownloaderBase, - pub(crate) cache_credentials: std::cell::Cell, + cache_credentials: std::cell::Cell, } impl_php_class!(SvnDownloader, r"Composer\Downloader\SvnDownloader"); @@ -41,7 +41,7 @@ impl SvnDownloader { } } - pub(crate) fn execute( + fn execute( &self, package: PackageInterfaceHandle, base_url: &str, @@ -67,7 +67,7 @@ impl SvnDownloader { }) } - pub(crate) async fn discard_changes(&self, path: &str) -> anyhow::Result> { + async fn discard_changes(&self, path: &str) -> anyhow::Result> { let mut output = String::new(); if self.inner.process.borrow_mut().execute_args( ["svn", "revert", "-R", "."].map(|s| s.to_string()).as_ref(), diff --git a/crates/shirabe/src/downloader/transport_exception.rs b/crates/shirabe/src/downloader/transport_exception.rs index da8b4c50..c9e1a092 100644 --- a/crates/shirabe/src/downloader/transport_exception.rs +++ b/crates/shirabe/src/downloader/transport_exception.rs @@ -5,10 +5,10 @@ use shirabe_php_shim::{PhpMixed, RuntimeException}; #[derive(Debug, Clone)] pub struct TransportException { inner: RuntimeException, - pub(crate) headers: Option>, - pub(crate) response: Option, - pub(crate) status_code: Option, - pub(crate) response_info: Vec, + headers: Option>, + response: Option, + status_code: Option, + response_info: Vec, } impl TransportException { -- cgit v1.3.1-4-g156e