aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 00:59:54 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 01:03:45 +0900
commit3a388b98a9aa6a14b1c7f7dc909c109cf9837800 (patch)
tree593e342313c6e6bd3ec2943a1690b8798e0a83ae /crates/shirabe/src/command
parentaad468e8b75ffc3e87ea6dfa22c53a8299fc08da (diff)
downloadphp-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.tar.gz
php-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.tar.zst
php-shirabe-3a388b98a9aa6a14b1c7f7dc909c109cf9837800.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/base_command.rs10
-rw-r--r--crates/shirabe/src/command/config_command.rs13
-rw-r--r--crates/shirabe/src/command/create_project_command.rs2
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs8
-rw-r--r--crates/shirabe/src/command/init_command.rs13
-rw-r--r--crates/shirabe/src/command/show_command.rs34
6 files changed, 37 insertions, 43 deletions
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index 9eb28dd8..d7f935c1 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -38,16 +38,16 @@ pub const INVALID: i64 = 2;
#[derive(Debug)]
pub struct BaseCommandData {
inner: CommandData,
- pub(crate) composer: std::cell::RefCell<Option<PartialComposerHandle>>,
- pub(crate) io: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>>,
+ composer: std::cell::RefCell<Option<PartialComposerHandle>>,
+ io: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<dyn IOInterface>>>>,
/// The definition entries that were registered through the Composer-typed
/// InputArgument/InputOption (which carry the suggested-values backport). PHP checks
/// `$definition->getArgument($name) instanceof Composer\Console\Input\InputArgument`; in
/// this port `set_definition` converts the entries to the Symfony types for storage, so
/// the Composer-typedness is tracked by name in these side maps instead.
- pub(crate) composer_arguments:
+ composer_arguments:
std::cell::RefCell<IndexMap<String, std::rc::Rc<crate::console::input::InputArgument>>>,
- pub(crate) composer_options:
+ composer_options:
std::cell::RefCell<IndexMap<String, std::rc::Rc<crate::console::input::InputOption>>>,
}
@@ -65,7 +65,7 @@ impl BaseCommandData {
/// Access to the embedded Symfony command state, used by the Composer-typed definition
/// builders to forward to `CommandData`'s Symfony-typed entry points. `CommandData` is
/// interior-mutable, so a shared reference is enough.
- pub(crate) fn command_data(&self) -> &CommandData {
+ fn command_data(&self) -> &CommandData {
&self.inner
}
}
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 3d92de4b..504a0f11 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -38,16 +38,15 @@ pub struct ConfigCommand {
config_file: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<JsonFile>>>>,
config_source: std::cell::RefCell<Option<JsonConfigSource>>,
- pub(crate) auth_config_file:
- std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<JsonFile>>>>,
- pub(crate) auth_config_source: std::cell::RefCell<Option<JsonConfigSource>>,
+ auth_config_file: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<JsonFile>>>>,
+ auth_config_source: std::cell::RefCell<Option<JsonConfigSource>>,
}
impl_php_class!(ConfigCommand, r"Composer\Command\ConfigCommand");
impl ConfigCommand {
/// List of additional configurable package-properties
- pub(crate) const CONFIGURABLE_PACKAGE_PROPERTIES: &'static [&'static str] = &[
+ const CONFIGURABLE_PACKAGE_PROPERTIES: &'static [&'static str] = &[
"name",
"type",
"description",
@@ -77,7 +76,7 @@ impl ConfigCommand {
command
}
- pub(crate) fn handle_single_value(
+ fn handle_single_value(
&self,
key: &str,
callbacks: &(ValidatorFn, NormalizerFn),
@@ -143,7 +142,7 @@ impl ConfigCommand {
Ok(())
}
- pub(crate) fn handle_multi_value(
+ fn handle_multi_value(
&self,
key: &str,
callbacks: &(ValidatorFn, NormalizerFn),
@@ -181,7 +180,7 @@ impl ConfigCommand {
}
/// Display the contents of the file in a pretty formatted way
- pub(crate) fn list_configuration(
+ fn list_configuration(
&self,
contents: PhpMixed,
raw_contents: PhpMixed,
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index c7768f11..124f809b 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -56,7 +56,7 @@ pub struct CreateProjectCommand {
base_command_data: BaseCommandData,
/// @var SuggestedPackagesReporter
- pub(crate) suggested_packages_reporter:
+ suggested_packages_reporter:
std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<SuggestedPackagesReporter>>>>,
}
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 451b051c..4b148c09 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -50,11 +50,9 @@ use shirabe_symfony_process::ExecutableFinder;
pub struct DiagnoseCommand {
base_command_data: BaseCommandData,
- pub(crate) http_downloader:
- std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<HttpDownloader>>>>,
- pub(crate) process:
- std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>>,
- pub(crate) exit_code: std::cell::Cell<i64>,
+ http_downloader: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<HttpDownloader>>>>,
+ process: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>>,
+ exit_code: std::cell::Cell<i64>,
}
impl_php_class!(DiagnoseCommand, r"Composer\Command\DiagnoseCommand");
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index 7e6021a9..c348fa6f 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -125,10 +125,7 @@ impl InitCommand {
.into())
}
- pub(crate) fn format_authors(
- &self,
- author: &str,
- ) -> anyhow::Result<Vec<IndexMap<String, PhpMixed>>> {
+ fn format_authors(&self, author: &str) -> anyhow::Result<Vec<IndexMap<String, PhpMixed>>> {
let parsed = self.parse_author_string(author)?;
let mut author_map: IndexMap<String, PhpMixed> = IndexMap::new();
let name = parsed.get("name").cloned().unwrap_or(None);
@@ -163,7 +160,7 @@ impl InitCommand {
Some(implode("\\", &namespace))
}
- pub(crate) fn get_git_config(&self) -> IndexMap<String, String> {
+ fn get_git_config(&self) -> IndexMap<String, String> {
if self.git_config.borrow().is_some() {
return self.git_config.borrow().clone().unwrap_or_default();
}
@@ -208,7 +205,7 @@ impl InitCommand {
/// "/$vendor/"
/// "/$vendor/*"
/// "$vendor/*"
- pub(crate) fn has_vendor_ignore(&self, ignore_file: &str, vendor: &str) -> bool {
+ fn has_vendor_ignore(&self, ignore_file: &str, vendor: &str) -> bool {
if !file_exists(ignore_file) {
return false;
}
@@ -225,7 +222,7 @@ impl InitCommand {
false
}
- pub(crate) fn add_vendor_ignore(&self, ignore_file: &str, vendor: &str) {
+ fn add_vendor_ignore(&self, ignore_file: &str, vendor: &str) {
let mut contents = String::new();
if file_exists(ignore_file) {
contents = file_get_contents(ignore_file).unwrap_or_default();
@@ -269,7 +266,7 @@ impl InitCommand {
self.add_vendor_ignore(ignore_file, vendor)
}
- pub(crate) fn is_valid_email(&self, email: &str) -> bool {
+ fn is_valid_email(&self, email: &str) -> bool {
shirabe_php_shim::filter_var_email(email)
}
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index f2246cbe..ead034da 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -55,8 +55,8 @@ use shirabe_symfony_console::output::OutputInterface;
pub struct ShowCommand {
base_command_data: BaseCommandData,
- pub(crate) version_parser: std::cell::RefCell<VersionParser>,
- pub(crate) colors: std::cell::RefCell<Vec<String>>,
+ version_parser: std::cell::RefCell<VersionParser>,
+ colors: std::cell::RefCell<Vec<String>>,
repository_set: std::cell::RefCell<Option<std::rc::Rc<std::cell::RefCell<RepositorySet>>>>,
}
@@ -83,7 +83,7 @@ impl ShowCommand {
}
/// PHP: protected function suggestPackageBasedOnMode(): \Closure
- pub(crate) fn suggest_package_based_on_mode(&self) -> crate::console::input::SuggestedValues {
+ fn suggest_package_based_on_mode(&self) -> crate::console::input::SuggestedValues {
crate::console::input::SuggestedValues::Closure(Box::new(|this, input, suggestions| {
if input.get_option("available")?.to_bool() || input.get_option("all")?.to_bool() {
return this.suggest_available_package_incl_platform().call(
@@ -259,7 +259,7 @@ impl ShowCommand {
}
}
- pub(crate) fn get_root_requires(&self) -> Vec<String> {
+ fn get_root_requires(&self) -> Vec<String> {
let composer_rc = self.try_composer(None, None);
let composer_rc = match composer_rc {
None => return vec![],
@@ -279,7 +279,7 @@ impl ShowCommand {
combined.keys().map(|k| strtolower(k)).collect()
}
- pub(crate) fn get_version_style(
+ fn get_version_style(
&self,
latest_package: PackageInterfaceHandle,
package: PackageInterfaceHandle,
@@ -294,7 +294,7 @@ impl ShowCommand {
}
/// finds a package by name and version if provided
- pub(crate) fn get_package(
+ fn get_package(
&self,
installed_repo: &RepositoryInterfaceHandle,
repos: &RepositoryInterfaceHandle,
@@ -371,7 +371,7 @@ impl ShowCommand {
}
/// Prints package info.
- pub(crate) fn print_package_info(
+ fn print_package_info(
&self,
package: CompletePackageInterfaceHandle,
versions: &IndexMap<String, String>,
@@ -401,7 +401,7 @@ impl ShowCommand {
}
/// Prints package metadata.
- pub(crate) fn print_meta(
+ fn print_meta(
&self,
package: CompletePackageInterfaceHandle,
versions: &IndexMap<String, String>,
@@ -564,7 +564,7 @@ impl ShowCommand {
}
/// Prints all available versions of this package and highlights the installed one if any.
- pub(crate) fn print_versions(
+ fn print_versions(
&self,
package: CompletePackageInterfaceHandle,
versions: &IndexMap<String, String>,
@@ -599,7 +599,7 @@ impl ShowCommand {
}
/// print link objects
- pub(crate) fn print_links(
+ fn print_links(
&self,
package: CompletePackageInterfaceHandle,
link_type: &str,
@@ -622,7 +622,7 @@ impl ShowCommand {
}
/// Prints the licenses of a package with metadata
- pub(crate) fn print_licenses(&self, package: CompletePackageInterfaceHandle) {
+ fn print_licenses(&self, package: CompletePackageInterfaceHandle) {
let spdx_licenses = SpdxLicenses::new();
let licenses = package.get_license();
@@ -650,7 +650,7 @@ impl ShowCommand {
}
/// Prints package info in JSON format.
- pub(crate) fn print_package_info_as_json(
+ fn print_package_info_as_json(
&self,
package: CompletePackageInterfaceHandle,
versions: &IndexMap<String, String>,
@@ -971,7 +971,7 @@ impl ShowCommand {
}
/// Init styles for tree
- pub(crate) fn init_styles(&self, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>) {
+ fn init_styles(&self, output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>) {
*self.colors.borrow_mut() = vec![
"green".to_string(),
"yellow".to_string(),
@@ -991,7 +991,7 @@ impl ShowCommand {
}
/// Display the tree
- pub(crate) fn display_package_tree(&self, array_tree: Vec<IndexMap<String, PhpMixed>>) {
+ fn display_package_tree(&self, array_tree: Vec<IndexMap<String, PhpMixed>>) {
for package in array_tree.iter() {
let name = package
.get("name")
@@ -1070,7 +1070,7 @@ impl ShowCommand {
}
/// Generate the package tree
- pub(crate) fn generate_package_tree(
+ fn generate_package_tree(
&self,
package: PackageInterfaceHandle,
installed_repo: &RepositoryInterfaceHandle,
@@ -1147,7 +1147,7 @@ impl ShowCommand {
}
/// Display a package tree
- pub(crate) fn display_tree(
+ fn display_tree(
&self,
package: &PhpMixed,
packages_in_tree: &[PhpMixed],
@@ -1216,7 +1216,7 @@ impl ShowCommand {
}
/// Display a package tree
- pub(crate) fn add_tree(
+ fn add_tree(
&self,
name: &str,
link: &Link,