diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-28 17:45:06 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-28 17:45:26 +0900 |
| commit | 53f1fb395f33e0fb8db9aebd09ea9082f650f9f1 (patch) | |
| tree | f9e8bf0e9d4b1e98cce383574fb6a13b684fff08 /crates/shirabe | |
| parent | 212f5cd75b1403ee75ffa44d7ebdb181174340c0 (diff) | |
| download | php-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.tar.gz php-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.tar.zst php-shirabe-53f1fb395f33e0fb8db9aebd09ea9082f650f9f1.zip | |
refactor: add linter
Diffstat (limited to 'crates/shirabe')
261 files changed, 1222 insertions, 1549 deletions
diff --git a/crates/shirabe/src/advisory/mod.rs b/crates/shirabe/src/advisory.rs index dbb90bd..dbb90bd 100644 --- a/crates/shirabe/src/advisory/mod.rs +++ b/crates/shirabe/src/advisory.rs diff --git a/crates/shirabe/src/advisory/audit_config.rs b/crates/shirabe/src/advisory/audit_config.rs index 28e5e68..458ebef 100644 --- a/crates/shirabe/src/advisory/audit_config.rs +++ b/crates/shirabe/src/advisory/audit_config.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Advisory/AuditConfig.php -use indexmap::IndexMap; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; - use crate::advisory::Auditor; use crate::config::Config; +use indexmap::IndexMap; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed}; #[derive(Debug, Clone)] pub struct AuditConfig { diff --git a/crates/shirabe/src/advisory/auditor.rs b/crates/shirabe/src/advisory/auditor.rs index 4331b7b..be78f4b 100644 --- a/crates/shirabe/src/advisory/auditor.rs +++ b/crates/shirabe/src/advisory/auditor.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Advisory/Auditor.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_php_shim::{ - DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists, - array_keys, array_reduce, get_class, sprintf, str_starts_with, -}; - use crate::advisory::AnySecurityAdvisory; use crate::advisory::SecurityAdvisory; use crate::io::ConsoleIO; @@ -19,6 +10,14 @@ use crate::package::PackageInterfaceHandle; use crate::package::base_package; use crate::repository::RepositorySet; use crate::util::PackageInfo; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_php_shim::{ + DATE_ATOM, InvalidArgumentException, PhpMixed, array_all, array_any, array_key_exists, + array_keys, array_reduce, get_class, sprintf, str_starts_with, +}; /// Shape of the `--format=json` audit output. #[derive(serde::Serialize)] diff --git a/crates/shirabe/src/advisory/security_advisory.rs b/crates/shirabe/src/advisory/security_advisory.rs index 78a2562..298a9e6 100644 --- a/crates/shirabe/src/advisory/security_advisory.rs +++ b/crates/shirabe/src/advisory/security_advisory.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Advisory/SecurityAdvisory.php +use crate::advisory::IgnoredSecurityAdvisory; +use crate::advisory::PartialSecurityAdvisory; use chrono::{DateTime, Utc}; use indexmap::IndexMap; use shirabe_php_shim::DATE_RFC3339; use shirabe_semver::constraint::AnyConstraint; -use crate::advisory::IgnoredSecurityAdvisory; -use crate::advisory::PartialSecurityAdvisory; - fn serialize_date_rfc3339<S: serde::Serializer>( dt: &DateTime<Utc>, serializer: S, diff --git a/crates/shirabe/src/autoload/mod.rs b/crates/shirabe/src/autoload.rs index d5758b2..d5758b2 100644 --- a/crates/shirabe/src/autoload/mod.rs +++ b/crates/shirabe/src/autoload.rs diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs index 133348c..e7acb0a 100644 --- a/crates/shirabe/src/autoload/autoload_generator.rs +++ b/crates/shirabe/src/autoload/autoload_generator.rs @@ -1,20 +1,5 @@ //! ref: composer/src/Composer/Autoload/AutoloadGenerator.php -use indexmap::IndexMap; - -use shirabe_class_map_generator::class_map::ClassMap; -use shirabe_class_map_generator::class_map_generator::ClassMapGenerator; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map, - array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode, - file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote, - random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr, - substr, substr_count, trim, unlink, var_export, -}; -use shirabe_semver::constraint::Bound; - use crate::autoload::ClassLoader; use crate::config::Config; use crate::event_dispatcher::EventDispatcher; @@ -34,6 +19,19 @@ use crate::script::ScriptEvents; use crate::util::Filesystem; use crate::util::PackageSorter; use crate::util::Platform; +use indexmap::IndexMap; +use shirabe_class_map_generator::class_map::ClassMap; +use shirabe_class_map_generator::class_map_generator::ClassMapGenerator; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map, + array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode, + file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote, + random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr, + substr, substr_count, trim, unlink, var_export, +}; +use shirabe_semver::constraint::Bound; #[derive(Debug)] pub struct AutoloadGenerator { diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs index 3889ca0..3ebb7a7 100644 --- a/crates/shirabe/src/autoload/class_loader.rs +++ b/crates/shirabe/src/autoload/class_loader.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Autoload/ClassLoader.php use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_php_shim::{ DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, defined, file_exists, include_file, spl_autoload_register, spl_autoload_unregister, stream_resolve_include_path, strlen, strpos, strrpos, strtr, substr, }; +use std::sync::{LazyLock, Mutex}; /// @var array<string, self> static REGISTERED_LOADERS: LazyLock<Mutex<IndexMap<String, ClassLoader>>> = diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs index 20197cd..b2e2f3f 100644 --- a/crates/shirabe/src/cache.rs +++ b/crates/shirabe/src/cache.rs @@ -1,7 +1,10 @@ //! ref: composer/src/Composer/Cache.php -use std::sync::Mutex; - +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::Silencer; use anyhow::Result; use chrono::Utc; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -11,12 +14,7 @@ use shirabe_php_shim::{ file_exists, file_get_contents, file_put_contents, filemtime, function_exists, hash_file, is_dir, is_writable, mkdir, random_bytes, random_int, rename, time, unlink, }; - -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::Silencer; +use std::sync::Mutex; /// Reads/writes to a filesystem cache #[derive(Debug)] diff --git a/crates/shirabe/src/command/mod.rs b/crates/shirabe/src/command.rs index 614fff7..614fff7 100644 --- a/crates/shirabe/src/command/mod.rs +++ b/crates/shirabe/src/command.rs diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs index 6aae55d..94c877a 100644 --- a/crates/shirabe/src/command/about_command.rs +++ b/crates/shirabe/src/command/about_command.rs @@ -1,5 +1,9 @@ //! ref: composer/src/Composer/Command/AboutCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::composer; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -7,11 +11,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::composer; - #[derive(Debug)] pub struct AboutCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs index d593912..91e8036 100644 --- a/crates/shirabe/src/command/archive_command.rs +++ b/crates/shirabe/src/command/archive_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/ArchiveCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{LogicException, get_debug_type}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::composer::PartialComposerHandle; @@ -32,6 +22,15 @@ use crate::util::Filesystem; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::r#loop::Loop; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{LogicException, get_debug_type}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ArchiveCommand { diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs index 0cf64a3..59d11a6 100644 --- a/crates/shirabe/src/command/audit_command.rs +++ b/crates/shirabe/src/command/audit_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/AuditCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::AuditConfig; use crate::advisory::Auditor; use crate::command::BaseCommand; @@ -21,6 +11,15 @@ use crate::io::IOInterfaceImmutable; use crate::repository::CanonicalPackagesTrait; use crate::repository::RepositorySet; use crate::repository::RepositoryUtils; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, implode, in_array, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct AuditCommand { diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs index 149dc09..46ee5f7 100644 --- a/crates/shirabe/src/command/base_command.rs +++ b/crates/shirabe/src/command/base_command.rs @@ -1,23 +1,6 @@ //! ref: composer/src/Composer/Command/BaseCommand.php //! ref: composer/vendor/symfony/console/Command/Command.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::Terminal; -use shirabe_external_packages::symfony::console::command::command::{ - Command, CommandData, SetDefinitionArg, -}; -use shirabe_external_packages::symfony::console::helper::Table; -use shirabe_external_packages::symfony::console::helper::TableSeparator; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException, - count, explode, in_array, is_string, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::AuditConfig; use crate::advisory::Auditor; use crate::composer::PartialComposerHandle; @@ -34,6 +17,22 @@ use crate::package::version::VersionParser; use crate::plugin::PluginEvents; use crate::plugin::PreCommandRunEvent; use crate::util::Platform; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::Terminal; +use shirabe_external_packages::symfony::console::command::command::{ + Command, CommandData, SetDefinitionArg, +}; +use shirabe_external_packages::symfony::console::helper::Table; +use shirabe_external_packages::symfony::console::helper::TableSeparator; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, UnexpectedValueException, + count, explode, in_array, is_string, +}; +use std::cell::RefCell; +use std::rc::Rc; pub const SUCCESS: i64 = 0; pub const FAILURE: i64 = 1; diff --git a/crates/shirabe/src/command/base_dependency_command.rs b/crates/shirabe/src/command/base_dependency_command.rs index 1c48a06..8b4fb14 100644 --- a/crates/shirabe/src/command/base_dependency_command.rs +++ b/crates/shirabe/src/command/base_dependency_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/BaseDependencyCommand.php -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, UnexpectedValueException}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::Bound; - use crate::command::BaseCommand; use crate::io::IOInterfaceImmutable; use crate::package::Package; @@ -22,6 +13,14 @@ use crate::repository::RootPackageRepository; use crate::repository::{DependentsEntry, InstalledRepository, NeedleInput}; use crate::repository::{FindPackageConstraint, RepositoryInterface}; use crate::util::PackageInfo; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, UnexpectedValueException}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::Bound; pub const ARGUMENT_PACKAGE: &str = "package"; pub const ARGUMENT_CONSTRAINT: &str = "version"; diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs index 3964300..79fedfb 100644 --- a/crates/shirabe/src/command/bump_command.rs +++ b/crates/shirabe/src/command/bump_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/BumpCommand.php -use crate::io::io_interface; -use crate::package::base_package; -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputArgument; @@ -18,12 +7,22 @@ use crate::console::input::InputOption; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::json::JsonManipulator; +use crate::package::base_package; use crate::package::version::VersionBumper; use crate::repository::PlatformRepository; use crate::util::Filesystem; use crate::util::Silencer; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, file_get_contents, file_put_contents, is_writable, strtolower}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct BumpCommand { @@ -180,7 +179,7 @@ impl BumpCommand { let unique_lower: Vec<String> = packages_filter .iter() .map(|s| strtolower(s)) - .collect::<std::collections::HashSet<_>>() + .collect::<indexmap::IndexSet<_>>() .into_iter() .collect(); let pattern = base_package::package_names_to_regexp(&unique_lower, "{^(?:%s)$}iD"); diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs index ee98aa8..4b4e043 100644 --- a/crates/shirabe/src/command/check_platform_reqs_command.rs +++ b/crates/shirabe/src/command/check_platform_reqs_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/CheckPlatformReqsCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputOption; @@ -21,6 +10,16 @@ use crate::repository::InstalledRepository; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RootPackageRepository; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, array_merge_map, strip_tags}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Rc; struct CheckResult { platform_package: String, diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs index abe72ec..696b1dc 100644 --- a/crates/shirabe/src/command/clear_cache_command.rs +++ b/crates/shirabe/src/command/clear_cache_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/ClearCacheCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::realpath; -use std::cell::RefCell; -use std::rc::Rc; - use crate::cache::Cache; use crate::command::BaseCommand; use crate::command::BaseCommandData; @@ -16,6 +8,13 @@ use crate::config::Config; use crate::console::input::InputOption; use crate::factory::Factory; use crate::io::IOInterfaceImmutable; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::realpath; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ClearCacheCommand { diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs index 7bf7d1b..e1ebf1a 100644 --- a/crates/shirabe/src/command/config_command.rs +++ b/crates/shirabe/src/command/config_command.rs @@ -1,21 +1,5 @@ //! ref: composer/src/Composer/Command/ConfigCommand.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; - -use crate::console::input::InputOption; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, - escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array, - is_bool, is_dir, is_numeric, is_object, is_string, json_encode, str_replace, strpos, - strtolower, system, touch, var_export, -}; - use crate::advisory::Auditor; use crate::command::BaseConfigCommand; use crate::command::{BaseCommand, BaseCommandData}; @@ -23,13 +7,27 @@ use crate::config::Config; use crate::config::ConfigSourceInterface; use crate::config::JsonConfigSource; use crate::console::input::InputArgument; +use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::package::base_package::{self}; use crate::util::Filesystem; use crate::util::Platform; use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_is_list, array_merge, + escapeshellcmd, exec, explode, file_exists, file_get_contents, implode, in_array, is_array, + is_bool, is_dir, is_numeric, is_object, is_string, json_encode, str_replace, strpos, + strtolower, system, touch, var_export, +}; use shirabe_semver::VersionParser; #[derive(Debug)] diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs index abbf37a..8f01f98 100644 --- a/crates/shirabe/src/command/create_project_command.rs +++ b/crates/shirabe/src/command/create_project_command.rs @@ -1,22 +1,5 @@ //! ref: composer/src/Composer/Command/CreateProjectCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_external_packages::symfony::finder::Finder; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, RuntimeException, - UnexpectedValueException, array_pop, chdir, explode_with_limit, file_exists, getcwd, implode, - is_dir, is_file, mkdir, realpath, rtrim, strtolower, unlink, -}; -use std::cell::RefCell; -use std::path::PathBuf; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -49,6 +32,22 @@ use crate::script::ScriptEvents; use crate::util::Filesystem; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_external_packages::symfony::finder::Finder; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, RuntimeException, + UnexpectedValueException, array_pop, chdir, explode_with_limit, file_exists, getcwd, implode, + is_dir, is_file, mkdir, realpath, rtrim, strtolower, unlink, +}; +use std::cell::RefCell; +use std::path::PathBuf; +use std::rc::Rc; /// Install a package as new project into new directory. #[derive(Debug)] diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs index fa60a42..39e916a 100644 --- a/crates/shirabe/src/command/depends_command.rs +++ b/crates/shirabe/src/command/depends_command.rs @@ -1,18 +1,17 @@ //! ref: composer/src/Composer/Command/DependsCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::BaseDependencyCommand; use crate::command::base_command::base_command_initialize; use crate::console::input::InputArgument; use crate::console::input::InputOption; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DependsCommand { diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs index 0bdf8ef..656f730 100644 --- a/crates/shirabe/src/command/diagnose_command.rs +++ b/crates/shirabe/src/command/diagnose_command.rs @@ -1,25 +1,5 @@ //! ref: composer/src/Composer/Command/DiagnoseCommand.php -use anyhow::Result; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_external_packages::symfony::process::ExecutableFinder; -use shirabe_php_shim::{ - INFO_GENERAL, InvalidArgumentException, OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT, - PHP_BINARY, PHP_EOL, PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, defined, - disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists, - get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version, - is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, str_contains, str_replace, - str_starts_with, strpos, strstr, strtolower, trim, version_compare, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -52,6 +32,24 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::http::ProxyManager; use crate::util::http::RequestProxy; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_external_packages::symfony::process::ExecutableFinder; +use shirabe_php_shim::{ + INFO_GENERAL, InvalidArgumentException, OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT, + PHP_BINARY, PHP_EOL, PHP_VERSION, PHP_VERSION_ID, PHP_WINDOWS_VERSION_BUILD, PhpMixed, defined, + disk_free_space, extension_loaded, file_exists, filter_var_boolean, function_exists, + get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version, + is_array, is_string, ob_get_clean, ob_start, phpinfo, rtrim, str_contains, str_replace, + str_starts_with, strpos, strstr, strtolower, trim, version_compare, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DiagnoseCommand { diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs index b0bb755..baae79d 100644 --- a/crates/shirabe/src/command/dump_autoload_command.rs +++ b/crates/shirabe/src/command/dump_autoload_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/DumpAutoloadCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -15,6 +7,13 @@ use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct DumpAutoloadCommand { diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs index 8f3a0b5..8b7d5f7 100644 --- a/crates/shirabe/src/command/exec_command.rs +++ b/crates/shirabe/src/command/exec_command.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Command/ExecCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -8,13 +14,6 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; - #[derive(Debug)] pub struct ExecCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs index 7e3bf65..ad4f94f 100644 --- a/crates/shirabe/src/command/fund_command.rs +++ b/crates/shirabe/src/command/fund_command.rs @@ -1,5 +1,13 @@ //! ref: composer/src/Composer/Command/FundCommand.php +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; +use crate::package::base_package::{self}; +use crate::repository::CompositeRepository; +use crate::repository::RepositoryInterface; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -13,15 +21,6 @@ use shirabe_semver::constraint::MatchAllConstraint; use std::cell::RefCell; use std::rc::Rc; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::package::base_package::{self}; -use crate::repository::CompositeRepository; -use crate::repository::RepositoryInterface; - #[derive(Debug)] pub struct FundCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index d0d8a31..04c2409 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -1,7 +1,12 @@ //! ref: composer/src/Composer/Command/GlobalCommand.php -use std::path::Path; - +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::factory::Factory; +use crate::util::Filesystem; +use crate::util::Platform; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::command::command::Command; @@ -12,16 +17,9 @@ use shirabe_external_packages::symfony::console::input::StringInput; use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_php_shim::{LogicException, RuntimeException, chdir}; use std::cell::RefCell; +use std::path::Path; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::factory::Factory; -use crate::util::Filesystem; -use crate::util::Platform; - #[derive(Debug)] pub struct GlobalCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs index bde9fc2..682cb6a 100644 --- a/crates/shirabe/src/command/home_command.rs +++ b/crates/shirabe/src/command/home_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/HomeCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use shirabe_php_shim::filter_var_url; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +11,14 @@ use crate::repository::RepositoryFactory; use crate::repository::RootPackageRepository; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::filter_var_url; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct HomeCommand { diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs index 88a2934..dc91069 100644 --- a/crates/shirabe/src/command/init_command.rs +++ b/crates/shirabe/src/command/init_command.rs @@ -1,6 +1,22 @@ //! ref: composer/src/Composer/Command/InitCommand.php +use crate::command::PackageDiscoveryTrait; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::factory::Factory; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::json::JsonFile; +use crate::json::JsonValidationException; +use crate::package::base_package::{self}; +use crate::repository::CompositeRepository; +use crate::repository::PlatformRepository; +use crate::repository::PlatformRepositoryHandle; +use crate::repository::RepositoryFactory; +use crate::util::Filesystem; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -19,23 +35,6 @@ use shirabe_spdx_licenses::SpdxLicenses; use std::cell::RefCell; use std::rc::Rc; -use crate::command::PackageDiscoveryTrait; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::factory::Factory; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::json::JsonValidationException; -use crate::package::base_package::{self}; -use crate::repository::CompositeRepository; -use crate::repository::PlatformRepository; -use crate::repository::PlatformRepositoryHandle; -use crate::repository::RepositoryFactory; -use crate::util::Filesystem; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - #[derive(Debug)] pub struct InitCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs index de0f400..2f782cc 100644 --- a/crates/shirabe/src/command/install_command.rs +++ b/crates/shirabe/src/command/install_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/InstallCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::BaseCommand; use crate::command::BaseCommandData; @@ -19,6 +11,13 @@ use crate::io::IOInterfaceImmutable; use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::util::HttpDownloader; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct InstallCommand { diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs index cae79e4..c5cdf2a 100644 --- a/crates/shirabe/src/command/licenses_command.rs +++ b/crates/shirabe/src/command/licenses_command.rs @@ -1,5 +1,16 @@ //! ref: composer/src/Composer/Command/LicensesCommand.php +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; +use crate::plugin::CommandEvent; +use crate::plugin::PluginEvents; +use crate::repository::RepositoryInterface; +use crate::repository::RepositoryUtils; +use crate::util::PackageInfo; +use crate::util::PackageSorter; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; @@ -13,18 +24,6 @@ use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException}; use std::cell::RefCell; use std::rc::Rc; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; -use crate::plugin::CommandEvent; -use crate::plugin::PluginEvents; -use crate::repository::RepositoryInterface; -use crate::repository::RepositoryUtils; -use crate::util::PackageInfo; -use crate::util::PackageSorter; - #[derive(Debug)] pub struct LicensesCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs index 90c0f3d..be921e1 100644 --- a/crates/shirabe/src/command/outdated_command.rs +++ b/crates/shirabe/src/command/outdated_command.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Command/OutdatedCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::console::command::command::Command; @@ -10,12 +15,6 @@ use shirabe_php_shim::PhpMixed; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; - #[derive(Debug)] pub struct OutdatedCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs index 4a5c65b..c3f744c 100644 --- a/crates/shirabe/src/command/package_discovery_trait.rs +++ b/crates/shirabe/src/command/package_discovery_trait.rs @@ -1,24 +1,12 @@ //! ref: composer/src/Composer/Command/PackageDiscoveryTrait.php -use crate::io::io_interface; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys, - array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file, - is_numeric, json_decode, levenshtein, strlen, strpos, trim, -}; - use crate::command::BaseCommand; use crate::factory::Factory; use crate::filter::platform_requirement_filter::IgnoreAllPlatformRequirementFilter; use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::version::VersionParser; use crate::package::version::VersionSelector; @@ -29,6 +17,16 @@ use crate::repository::RepositoryFactory; use crate::repository::RepositorySet; use crate::repository::{RepositoryInterface, SearchResult}; use crate::util::Filesystem; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + Exception, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, array_keys, + array_slice, asort, explode, file_get_contents, implode, in_array, is_array, is_file, + is_numeric, json_decode, levenshtein, strlen, strpos, trim, +}; /// @internal pub trait PackageDiscoveryTrait: BaseCommand { diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs index 7c034aa..2423dc7 100644 --- a/crates/shirabe/src/command/prohibits_command.rs +++ b/crates/shirabe/src/command/prohibits_command.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Command/ProhibitsCommand.php +use crate::command::BaseDependencyCommand; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; use anyhow::Result; use shirabe_external_packages::symfony::console::command::command::Command; use shirabe_external_packages::symfony::console::input::InputInterface; @@ -7,12 +12,6 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseDependencyCommand; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; - #[derive(Debug)] pub struct ProhibitsCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs index b1d74cc..2cafbc3 100644 --- a/crates/shirabe/src/command/reinstall_command.rs +++ b/crates/shirabe/src/command/reinstall_command.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Command/ReinstallCommand.php -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::InvalidArgumentException; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -23,6 +14,14 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::script::ScriptEvents; use crate::util::Platform; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::InvalidArgumentException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ReinstallCommand { diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs index f864ebe..7422151 100644 --- a/crates/shirabe/src/command/remove_command.rs +++ b/crates/shirabe/src/command/remove_command.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Command/RemoveCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::exception::InvalidArgumentException; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; @@ -25,6 +14,16 @@ use crate::io::IOInterfaceImmutable; use crate::json::JsonFile; use crate::package::base_package; use crate::repository::RepositoryInterface; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::exception::InvalidArgumentException; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{PhpMixed, UnexpectedValueException, strtolower}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RemoveCommand { diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs index 19dfb6b..ba0778c 100644 --- a/crates/shirabe/src/command/repository_command.rs +++ b/crates/shirabe/src/command/repository_command.rs @@ -1,5 +1,14 @@ //! ref: composer/src/Composer/Command/RepositoryCommand.php +use crate::command::BaseConfigCommand; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::config::Config; +use crate::config::ConfigSourceInterface; +use crate::config::JsonConfigSource; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::io::IOInterfaceImmutable; +use crate::json::JsonFile; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -12,16 +21,6 @@ use shirabe_php_shim::{ use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseConfigCommand; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::config::Config; -use crate::config::ConfigSourceInterface; -use crate::config::JsonConfigSource; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonFile; - #[derive(Debug)] pub struct RepositoryCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 4f50e71..ebd090a 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -1,21 +1,5 @@ //! ref: composer/src/Composer/Command/RequireCommand.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map, - array_merge, array_unique, empty, file_exists, file_get_contents, file_put_contents, filesize, - implode, is_writable, strtolower, unlink, -}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::advisory::Auditor; use crate::command::PackageDiscoveryTrait; use crate::command::base_command::base_command_initialize; @@ -28,6 +12,7 @@ use crate::installer::Installer; use crate::installer::InstallerEvents; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::json::JsonManipulator; use crate::package::base_package; @@ -44,6 +29,20 @@ use crate::repository::RepositorySet; use crate::util::Filesystem; use crate::util::PackageSorter; use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map, + array_merge, array_unique, empty, file_exists, file_get_contents, file_put_contents, filesize, + implode, is_writable, strtolower, unlink, +}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RequireCommand { diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs index a85bb4e..869d97b 100644 --- a/crates/shirabe/src/command/run_script_command.rs +++ b/crates/shirabe/src/command/run_script_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/RunScriptCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use shirabe_php_shim::{InvalidArgumentException, RuntimeException}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +10,15 @@ use crate::script::Event as ScriptEvent; use crate::script::ScriptEvents; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::{InvalidArgumentException, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RunScriptCommand { diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs index 9f55b03..20e2901 100644 --- a/crates/shirabe/src/command/script_alias_command.rs +++ b/crates/shirabe/src/command/script_alias_command.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Command/ScriptAliasCommand.php +use crate::command::BaseCommand; +use crate::command::BaseCommandData; +use crate::command::base_command::base_command_initialize; +use crate::console::input::InputArgument; +use crate::console::input::InputOption; +use crate::util::Platform; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::command::command::Command; @@ -9,13 +15,6 @@ use shirabe_php_shim::{InvalidArgumentException, LogicException, PhpMixed, is_st use std::cell::RefCell; use std::rc::Rc; -use crate::command::BaseCommand; -use crate::command::BaseCommandData; -use crate::command::base_command::base_command_initialize; -use crate::console::input::InputArgument; -use crate::console::input::InputOption; -use crate::util::Platform; - #[derive(Debug)] pub struct ScriptAliasCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs index f902eb8..6f3f4ce 100644 --- a/crates/shirabe/src/command/search_command.rs +++ b/crates/shirabe/src/command/search_command.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Command/SearchCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, preg_quote}; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::console::input::InputArgument; @@ -22,6 +12,15 @@ use crate::repository::CompositeRepository; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; use crate::repository::repository_interface::{self, RepositoryInterface}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, implode, in_array, preg_quote}; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SearchCommand { diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs index 5b94058..ca567ce 100644 --- a/crates/shirabe/src/command/self_update_command.rs +++ b/crates/shirabe/src/command/self_update_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/SelfUpdateCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -15,6 +7,13 @@ use crate::console::input::InputArgument; use crate::console::input::InputOption; use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SelfUpdateCommand { diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs index c52e0bf..6e777a1 100644 --- a/crates/shirabe/src/command/show_command.rs +++ b/crates/shirabe/src/command/show_command.rs @@ -1,25 +1,5 @@ //! ref: composer/src/Composer/Command/ShowCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use shirabe_php_shim::{ - DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, - array_search, date, date_format_to_strftime, extension_loaded, in_array, realpath, strtolower, - version_compare, -}; -use shirabe_semver::Semver; -use shirabe_spdx_licenses::SpdxLicenses; -use std::cell::RefCell; -use std::rc::Rc; - -use shirabe_semver::constraint::AnyConstraint; - use crate::command::base_command::base_command_initialize; use crate::command::{BaseCommand, BaseCommandData}; use crate::composer::PartialComposerHandle; @@ -52,6 +32,24 @@ use crate::repository::RepositorySet; use crate::repository::RepositoryUtils; use crate::repository::RootPackageRepository; use crate::util::PackageInfo; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use shirabe_php_shim::{ + DATE_ATOM, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, + array_search, date, date_format_to_strftime, extension_loaded, in_array, realpath, strtolower, + version_compare, +}; +use shirabe_semver::Semver; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_spdx_licenses::SpdxLicenses; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ShowCommand { diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs index 74a85b4..bec6868 100644 --- a/crates/shirabe/src/command/status_command.rs +++ b/crates/shirabe/src/command/status_command.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Command/StatusCommand.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +12,13 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::script::ScriptEvents; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct StatusCommand { diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs index e602cc2..cce4829 100644 --- a/crates/shirabe/src/command/update_command.rs +++ b/crates/shirabe/src/command/update_command.rs @@ -1,10 +1,28 @@ //! ref: composer/src/Composer/Command/UpdateCommand.php use crate::advisory::Auditor; +use crate::command::BumpCommand; +use crate::command::base_command::base_command_initialize; +use crate::command::{BaseCommand, BaseCommandData}; +use crate::composer::PartialComposerHandle; use crate::console::input::InputArgument; use crate::console::input::InputOption; +use crate::dependency_resolver::request::UpdateAllowTransitiveDeps; +use crate::installer::Installer; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; use crate::package::base_package; +use crate::package::loader::RootPackageLoader; +use crate::package::version::VersionParser; +use crate::package::version::VersionSelector; +use crate::plugin::CommandEvent; +use crate::plugin::PluginEvents; +use crate::repository::CanonicalPackagesTrait; +use crate::repository::CompositeRepository; +use crate::repository::PlatformRepository; +use crate::repository::RepositorySet; +use crate::util::HttpDownloader; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -21,25 +39,6 @@ use shirabe_semver::constraint::MultiConstraint; use std::cell::RefCell; use std::rc::Rc; -use crate::command::BumpCommand; -use crate::command::base_command::base_command_initialize; -use crate::command::{BaseCommand, BaseCommandData}; -use crate::composer::PartialComposerHandle; -use crate::dependency_resolver::request::UpdateAllowTransitiveDeps; -use crate::installer::Installer; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::loader::RootPackageLoader; -use crate::package::version::VersionParser; -use crate::package::version::VersionSelector; -use crate::plugin::CommandEvent; -use crate::plugin::PluginEvents; -use crate::repository::CanonicalPackagesTrait; -use crate::repository::CompositeRepository; -use crate::repository::PlatformRepository; -use crate::repository::RepositorySet; -use crate::util::HttpDownloader; - #[derive(Debug)] pub struct UpdateCommand { base_command_data: BaseCommandData, diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs index fc9a7df..ab88398 100644 --- a/crates/shirabe/src/command/validate_command.rs +++ b/crates/shirabe/src/command/validate_command.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Command/ValidateCommand.php -use anyhow::Result; -use shirabe_external_packages::symfony::console::command::command::Command; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::output::OutputInterface; -use std::cell::RefCell; -use std::rc::Rc; - use crate::command::BaseCommand; use crate::command::BaseCommandData; use crate::command::base_command::base_command_initialize; @@ -20,6 +13,12 @@ use crate::plugin::CommandEvent; use crate::plugin::PluginEvents; use crate::util::ConfigValidator; use crate::util::Filesystem; +use anyhow::Result; +use shirabe_external_packages::symfony::console::command::command::Command; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::output::OutputInterface; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct ValidateCommand { diff --git a/crates/shirabe/src/composer.rs b/crates/shirabe/src/composer.rs index d6c41e2..e28fb00 100644 --- a/crates/shirabe/src/composer.rs +++ b/crates/shirabe/src/composer.rs @@ -1,8 +1,6 @@ //! ref: composer/src/Composer/Composer.php //! ref: composer/src/Composer/PartialComposer.php -use shirabe_external_packages::composer::pcre::Preg; - use crate::autoload::AutoloadGeneratorInterface; use crate::config::Config; use crate::downloader::DownloadManagerInterface; @@ -13,6 +11,7 @@ use crate::package::{LockerInterface, RootPackageInterfaceHandle}; use crate::plugin::PluginManager; use crate::repository::RepositoryManagerInterface; use crate::util::r#loop::Loop; +use shirabe_external_packages::composer::pcre::Preg; // TODO: change this information to Shirabe version. pub const VERSION: &str = "2.9.7"; diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs index 1ce51ad..1b09e54 100644 --- a/crates/shirabe/src/config/json_config_source.rs +++ b/crates/shirabe/src/config/json_config_source.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Config/JsonConfigSource.php +use crate::config::ConfigSourceInterface; +use crate::json::JsonFile; +use crate::json::JsonManipulator; +use crate::json::JsonValidationException; +use crate::util::Filesystem; use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; @@ -8,12 +13,6 @@ use shirabe_php_shim::{ implode, is_writable, }; -use crate::config::ConfigSourceInterface; -use crate::json::JsonFile; -use crate::json::JsonManipulator; -use crate::json::JsonValidationException; -use crate::util::Filesystem; - /// JSON Configuration Source #[derive(Debug)] pub struct JsonConfigSource { diff --git a/crates/shirabe/src/console/mod.rs b/crates/shirabe/src/console.rs index 9289d7e..9289d7e 100644 --- a/crates/shirabe/src/console/mod.rs +++ b/crates/shirabe/src/console.rs diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs index 3e197a2..077ea0a 100644 --- a/crates/shirabe/src/console/application.rs +++ b/crates/shirabe/src/console/application.rs @@ -1,58 +1,6 @@ //! ref: composer/src/Composer/Console/Application.php //! ref: composer/vendor/symfony/console/Application.php -use crate::io::io_interface; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_external_packages::seld::json_lint::ParsingException; -use shirabe_external_packages::symfony::console::application::Application as BaseApplication; -use shirabe_external_packages::symfony::console::command::Command as SymfonyCommand; -use shirabe_external_packages::symfony::console::command::help_command::HelpCommand; -use shirabe_external_packages::symfony::console::command::signalable_command_interface::SignalableCommandInterface; -use shirabe_external_packages::symfony::console::command_loader::command_loader_interface::CommandLoaderInterface; -use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; -use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions; -use shirabe_external_packages::symfony::console::exception::CommandNotFoundException; -use shirabe_external_packages::symfony::console::exception::invalid_argument_exception::InvalidArgumentException as ConsoleInvalidArgumentException; -use shirabe_external_packages::symfony::console::exception::invalid_option_exception::InvalidOptionException; -use shirabe_external_packages::symfony::console::exception::logic_exception::LogicException as ConsoleLogicException; -use shirabe_external_packages::symfony::console::exception::missing_input_exception::MissingInputException; -use shirabe_external_packages::symfony::console::exception::namespace_not_found_exception::NamespaceNotFoundException; -use shirabe_external_packages::symfony::console::exception::runtime_exception::RuntimeException as ConsoleRuntimeException; -use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::helper::HelperSet; -use shirabe_external_packages::symfony::console::helper::QuestionHelper; -use shirabe_external_packages::symfony::console::helper::formatter_helper::{ - FormatBlockMessages, FormatterHelper, -}; -use shirabe_external_packages::symfony::console::helper::helper::Helper; -use shirabe_external_packages::symfony::console::input::InputDefinition; -use shirabe_external_packages::symfony::console::input::InputInterface; -use shirabe_external_packages::symfony::console::input::InputOption; -use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput; -use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; -use shirabe_external_packages::symfony::console::input::input_argument::InputArgument; -use shirabe_external_packages::symfony::console::output::console_output::ConsoleOutput; -use shirabe_external_packages::symfony::console::output::output_interface::{ - self as output_interface, OutputInterface, -}; -use shirabe_external_packages::symfony::console::signal_registry::signal_registry::SignalRegistry; -use shirabe_external_packages::symfony::console::style::style_interface::StyleInterface; -use shirabe_external_packages::symfony::console::style::symfony_style::SymfonyStyle; -use shirabe_external_packages::symfony::console::terminal::Terminal; -use shirabe_external_packages::symfony::process::exception::ProcessTimedOutException; -use shirabe_php_shim::{ - LogicException as ShimLogicException, PHP_BINARY, PHP_VERSION, PHP_VERSION_ID, PhpMixed, - RuntimeException, bin2hex, chdir, date_default_timezone_get, date_default_timezone_set, - defined, dirname, disk_free_space, extension_loaded, file_exists, file_get_contents, - file_put_contents, function_exists, getcwd, getmypid, glob, in_array, ini_set, is_array, - is_dir, is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, - memory_get_usage, microtime, php_uname, posix_getuid, random_bytes, realpath, - restore_error_handler, round, str_contains, str_replace, strpos, strtoupper, sys_get_temp_dir, - time, unlink, -}; - use crate::command::AboutCommand; use crate::command::ArchiveCommand; use crate::command::AuditCommand; @@ -98,12 +46,62 @@ use crate::io::ConsoleIO; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::io::NullIO; +use crate::io::io_interface; use crate::json::JsonValidationException; use crate::util::ErrorHandler; use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::Silencer; +use indexmap::IndexMap; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_external_packages::seld::json_lint::ParsingException; +use shirabe_external_packages::symfony::console::application::Application as BaseApplication; +use shirabe_external_packages::symfony::console::command::Command as SymfonyCommand; +use shirabe_external_packages::symfony::console::command::help_command::HelpCommand; +use shirabe_external_packages::symfony::console::command::signalable_command_interface::SignalableCommandInterface; +use shirabe_external_packages::symfony::console::command_loader::command_loader_interface::CommandLoaderInterface; +use shirabe_external_packages::symfony::console::completion::completion_input::CompletionInput; +use shirabe_external_packages::symfony::console::completion::completion_suggestions::CompletionSuggestions; +use shirabe_external_packages::symfony::console::exception::CommandNotFoundException; +use shirabe_external_packages::symfony::console::exception::invalid_argument_exception::InvalidArgumentException as ConsoleInvalidArgumentException; +use shirabe_external_packages::symfony::console::exception::invalid_option_exception::InvalidOptionException; +use shirabe_external_packages::symfony::console::exception::logic_exception::LogicException as ConsoleLogicException; +use shirabe_external_packages::symfony::console::exception::missing_input_exception::MissingInputException; +use shirabe_external_packages::symfony::console::exception::namespace_not_found_exception::NamespaceNotFoundException; +use shirabe_external_packages::symfony::console::exception::runtime_exception::RuntimeException as ConsoleRuntimeException; +use shirabe_external_packages::symfony::console::formatter::output_formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::helper::HelperSet; +use shirabe_external_packages::symfony::console::helper::QuestionHelper; +use shirabe_external_packages::symfony::console::helper::formatter_helper::{ + FormatBlockMessages, FormatterHelper, +}; +use shirabe_external_packages::symfony::console::helper::helper::Helper; +use shirabe_external_packages::symfony::console::input::InputDefinition; +use shirabe_external_packages::symfony::console::input::InputInterface; +use shirabe_external_packages::symfony::console::input::InputOption; +use shirabe_external_packages::symfony::console::input::argv_input::ArgvInput; +use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; +use shirabe_external_packages::symfony::console::input::input_argument::InputArgument; +use shirabe_external_packages::symfony::console::output::console_output::ConsoleOutput; +use shirabe_external_packages::symfony::console::output::output_interface::{ + self, OutputInterface, +}; +use shirabe_external_packages::symfony::console::signal_registry::signal_registry::SignalRegistry; +use shirabe_external_packages::symfony::console::style::style_interface::StyleInterface; +use shirabe_external_packages::symfony::console::style::symfony_style::SymfonyStyle; +use shirabe_external_packages::symfony::console::terminal::Terminal; +use shirabe_external_packages::symfony::process::exception::ProcessTimedOutException; +use shirabe_php_shim::{ + LogicException as ShimLogicException, PHP_BINARY, PHP_VERSION, PHP_VERSION_ID, PhpMixed, + RuntimeException, bin2hex, chdir, date_default_timezone_get, date_default_timezone_set, + defined, dirname, disk_free_space, extension_loaded, file_exists, file_get_contents, + file_put_contents, function_exists, getcwd, getmypid, glob, in_array, ini_set, is_array, + is_dir, is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, + memory_get_usage, microtime, php_uname, posix_getuid, random_bytes, realpath, + restore_error_handler, round, str_contains, str_replace, strpos, strtoupper, sys_get_temp_dir, + time, unlink, +}; /// The PHP `Composer\Console\Application` and `Symfony\Component\Console\Application` are /// flattened into a single struct. Methods that are overridden by subclass and called via @@ -867,7 +865,7 @@ impl Application { merged.extend(ns); } let merged: Vec<String> = merged.into_iter().filter(|s| !s.is_empty()).collect(); - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); let unique: Vec<String> = merged .into_iter() .filter(|s| seen.insert(s.clone())) @@ -1044,7 +1042,7 @@ impl Application { let commands_clone = commands.clone(); let mut new_commands: Vec<String> = Vec::new(); - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); for name_or_alias in commands { if !command_list.contains_key(&name_or_alias) { let loaded = self.command_loader.as_ref().unwrap().get(&name_or_alias); diff --git a/crates/shirabe/src/console/input/mod.rs b/crates/shirabe/src/console/input.rs index 9141f0c..9141f0c 100644 --- a/crates/shirabe/src/console/input/mod.rs +++ b/crates/shirabe/src/console/input.rs diff --git a/crates/shirabe/src/dependency_resolver/mod.rs b/crates/shirabe/src/dependency_resolver.rs index bcde18b..bcde18b 100644 --- a/crates/shirabe/src/dependency_resolver/mod.rs +++ b/crates/shirabe/src/dependency_resolver.rs diff --git a/crates/shirabe/src/dependency_resolver/default_policy.rs b/crates/shirabe/src/dependency_resolver/default_policy.rs index 5b0981d..d56a96c 100644 --- a/crates/shirabe/src/dependency_resolver/default_policy.rs +++ b/crates/shirabe/src/dependency_resolver/default_policy.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/DefaultPolicy.php -use std::cell::RefCell; - -use indexmap::IndexMap; -use shirabe_semver::CompilingMatcher; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::PolicyInterface; use crate::dependency_resolver::Pool; use crate::package::BasePackageHandle; use crate::package::STABILITIES; use crate::util::Platform; +use indexmap::IndexMap; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; #[derive(Debug)] pub struct DefaultPolicy { diff --git a/crates/shirabe/src/dependency_resolver/generic_rule.rs b/crates/shirabe/src/dependency_resolver/generic_rule.rs index 9098e93..afab376 100644 --- a/crates/shirabe/src/dependency_resolver/generic_rule.rs +++ b/crates/shirabe/src/dependency_resolver/generic_rule.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/DependencyResolver/GenericRule.php +use super::rule::ReasonData; use crate::dependency_resolver::{Rule, RuleBase}; use anyhow::Result; use shirabe_php_shim::{PHP_VERSION_ID, RuntimeException, hash_raw, unpack}; -use super::rule::ReasonData; - #[derive(Debug)] pub struct GenericRule { inner: RuleBase, diff --git a/crates/shirabe/src/dependency_resolver/lock_transaction.rs b/crates/shirabe/src/dependency_resolver/lock_transaction.rs index 3cabdcd..fb34562 100644 --- a/crates/shirabe/src/dependency_resolver/lock_transaction.rs +++ b/crates/shirabe/src/dependency_resolver/lock_transaction.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/DependencyResolver/LockTransaction.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Pool; use crate::dependency_resolver::Transaction; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; #[derive(Debug)] pub struct LockTransaction { diff --git a/crates/shirabe/src/dependency_resolver/operation/mod.rs b/crates/shirabe/src/dependency_resolver/operation.rs index 720c5a0..720c5a0 100644 --- a/crates/shirabe/src/dependency_resolver/operation/mod.rs +++ b/crates/shirabe/src/dependency_resolver/operation.rs diff --git a/crates/shirabe/src/dependency_resolver/pool.rs b/crates/shirabe/src/dependency_resolver/pool.rs index 43d959b..1b072b4 100644 --- a/crates/shirabe/src/dependency_resolver/pool.rs +++ b/crates/shirabe/src/dependency_resolver/pool.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/Pool.php -use std::fmt; - +use crate::advisory::AnySecurityAdvisory; +use crate::package::BasePackageHandle; +use crate::package::version::VersionParser; use indexmap::IndexMap; use shirabe_php_shim::{STR_PAD_LEFT, str_pad}; use shirabe_semver::CompilingMatcher; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; - -use crate::advisory::AnySecurityAdvisory; -use crate::package::BasePackageHandle; -use crate::package::version::VersionParser; +use std::fmt; /// A package pool contains all packages for dependency resolution #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/pool_builder.rs b/crates/shirabe/src/dependency_resolver/pool_builder.rs index 986cbdf..5cfaa33 100644 --- a/crates/shirabe/src/dependency_resolver/pool_builder.rs +++ b/crates/shirabe/src/dependency_resolver/pool_builder.rs @@ -1,20 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/PoolBuilder.php -use crate::io::io_interface; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - LogicException, PhpMixed, array_flip_strings, array_map, in_array, microtime, number_format, - round, strpos, -}; -use shirabe_semver::CompilingMatcher; -use shirabe_semver::Intervals; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::MultiConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::PoolOptimizer; use crate::dependency_resolver::Request; @@ -22,6 +7,7 @@ use crate::dependency_resolver::SecurityAdvisoryPoolFilter; use crate::event_dispatcher::EventDispatcherInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::AliasPackageHandle; use crate::package::BasePackageHandle; use crate::package::CompleteAliasPackageHandle; @@ -32,6 +18,18 @@ use crate::repository::CanonicalPackagesTrait; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; use crate::repository::RootPackageRepository; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + LogicException, PhpMixed, array_flip_strings, array_map, in_array, microtime, number_format, + round, strpos, +}; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::Intervals; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::MultiConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct PoolBuilder { diff --git a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs index 3cc5551..6238ddb 100644 --- a/crates/shirabe/src/dependency_resolver/pool_optimizer.rs +++ b/crates/shirabe/src/dependency_resolver/pool_optimizer.rs @@ -1,7 +1,10 @@ //! ref: composer/src/Composer/DependencyResolver/PoolOptimizer.php -use std::rc::Rc; - +use crate::dependency_resolver::PolicyInterface; +use crate::dependency_resolver::Pool; +use crate::dependency_resolver::Request; +use crate::package::BasePackageHandle; +use crate::package::version::VersionParser; use indexmap::IndexMap; use shirabe_php_shim::{implode, ksort}; use shirabe_semver::CompilingMatcher; @@ -9,12 +12,7 @@ use shirabe_semver::Intervals; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; - -use crate::dependency_resolver::PolicyInterface; -use crate::dependency_resolver::Pool; -use crate::dependency_resolver::Request; -use crate::package::BasePackageHandle; -use crate::package::version::VersionParser; +use std::rc::Rc; /// Optimizes a given pool #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/problem.rs b/crates/shirabe/src/dependency_resolver/problem.rs index 230ebc3..ac05033 100644 --- a/crates/shirabe/src/dependency_resolver/problem.rs +++ b/crates/shirabe/src/dependency_resolver/problem.rs @@ -1,7 +1,15 @@ //! ref: composer/src/Composer/DependencyResolver/Problem.php +use crate::dependency_resolver::Pool; +use crate::dependency_resolver::Request; +use crate::dependency_resolver::rule::{self, Rule}; +use crate::package::BasePackageHandle; +use crate::package::Link; +use crate::package::version::VersionParser; +use crate::repository::LockArrayRepository; +use crate::repository::PlatformRepository; +use crate::repository::RepositorySet; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::symfony::console::formatter::OutputFormatter; use shirabe_php_shim::{ @@ -13,16 +21,6 @@ use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; -use crate::dependency_resolver::Pool; -use crate::dependency_resolver::Request; -use crate::dependency_resolver::rule::{self, Rule}; -use crate::package::BasePackageHandle; -use crate::package::Link; -use crate::package::version::VersionParser; -use crate::repository::LockArrayRepository; -use crate::repository::PlatformRepository; -use crate::repository::RepositorySet; - /// Represents a problem detected while solving dependencies #[derive(Debug)] pub struct Problem { diff --git a/crates/shirabe/src/dependency_resolver/request.rs b/crates/shirabe/src/dependency_resolver/request.rs index d3bcdfc..0a05f3e 100644 --- a/crates/shirabe/src/dependency_resolver/request.rs +++ b/crates/shirabe/src/dependency_resolver/request.rs @@ -1,14 +1,13 @@ //! ref: composer/src/Composer/DependencyResolver/Request.php +use crate::package::BasePackageHandle; +use crate::repository::LockArrayRepositoryHandle; +use crate::repository::RepositoryInterface; use indexmap::IndexMap; use shirabe_php_shim::{LogicException, strtolower}; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MatchAllConstraint; -use crate::package::BasePackageHandle; -use crate::repository::LockArrayRepositoryHandle; -use crate::repository::RepositoryInterface; - /// Identifies a partial update for listed packages only, all dependencies will remain at locked versions pub const UPDATE_ONLY_LISTED: i64 = 0; diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs index 306f633..958af5a 100644 --- a/crates/shirabe/src/dependency_resolver/rule.rs +++ b/crates/shirabe/src/dependency_resolver/rule.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Rule.php -use std::cell::RefCell; -use std::rc::Rc; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{ - LogicException, PhpMixed, RuntimeException, array_keys, array_shift, implode, -}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::MultiConflictRule; use crate::dependency_resolver::Pool; @@ -23,6 +12,15 @@ use crate::package::version::VersionParser; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositorySet; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + LogicException, PhpMixed, RuntimeException, array_keys, array_shift, implode, +}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub enum ReasonData { diff --git a/crates/shirabe/src/dependency_resolver/rule_set.rs b/crates/shirabe/src/dependency_resolver/rule_set.rs index d88f346..cde4ebc 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSet.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; -use shirabe_php_shim::OutOfBoundsException; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::Request; use crate::dependency_resolver::Rule; use crate::dependency_resolver::RuleSetIterator; use crate::repository::RepositorySet; +use indexmap::IndexMap; +use shirabe_php_shim::OutOfBoundsException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RuleSet { diff --git a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs index 1d9d0c4..6c2824e 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_generator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_generator.rs @@ -1,11 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSetGenerator.php -use std::cell::RefCell; -use std::collections::VecDeque; -use std::rc::Rc; - -use indexmap::IndexMap; - use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::MultiConflictRule; use crate::dependency_resolver::PolicyInterface; @@ -18,6 +12,10 @@ use crate::filter::platform_requirement_filter::IgnoreListPlatformRequirementFil use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use std::cell::RefCell; +use std::collections::VecDeque; +use std::rc::Rc; #[derive(Debug)] pub struct RuleSetGenerator { diff --git a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs index 91cfff2..2c4b9a4 100644 --- a/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs +++ b/crates/shirabe/src/dependency_resolver/rule_set_iterator.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/DependencyResolver/RuleSetIterator.php -use std::cell::RefCell; -use std::rc::Rc; - use crate::dependency_resolver::Rule; use indexmap::IndexMap; +use std::cell::RefCell; +use std::rc::Rc; /// Implements PHP \Iterator over a grouped rule set. #[derive(Debug)] diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs index 370d553..b746f50 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_graph.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/DependencyResolver/RuleWatchGraph.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Rule; use crate::dependency_resolver::RuleWatchChain; use crate::dependency_resolver::RuleWatchNode; +use indexmap::IndexMap; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct RuleWatchGraph { diff --git a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs index 7292ae0..92faae7 100644 --- a/crates/shirabe/src/dependency_resolver/rule_watch_node.rs +++ b/crates/shirabe/src/dependency_resolver/rule_watch_node.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/DependencyResolver/RuleWatchNode.php -use std::cell::RefCell; -use std::rc::Rc; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::Rule; +use std::cell::RefCell; +use std::rc::Rc; pub struct RuleWatchNode { pub watch1: i64, diff --git a/crates/shirabe/src/dependency_resolver/solver.rs b/crates/shirabe/src/dependency_resolver/solver.rs index 53a26ac..933f79f 100644 --- a/crates/shirabe/src/dependency_resolver/solver.rs +++ b/crates/shirabe/src/dependency_resolver/solver.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Solver.php -use std::cell::RefCell; -use std::rc::Rc; - -use indexmap::IndexMap; - -use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash}; -use shirabe_semver::constraint::AnyConstraint; - use crate::dependency_resolver::Decisions; use crate::dependency_resolver::GenericRule; use crate::dependency_resolver::LockTransaction; @@ -28,6 +20,11 @@ use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterfa use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::package::BasePackageHandle; +use indexmap::IndexMap; +use shirabe_php_shim::{array_shift, array_unshift, microtime, spl_object_hash}; +use shirabe_semver::constraint::AnyConstraint; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct Solver { diff --git a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs index d5f5560..b0016d0 100644 --- a/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs +++ b/crates/shirabe/src/dependency_resolver/solver_problems_exception.rs @@ -1,16 +1,14 @@ //! ref: composer/src/Composer/DependencyResolver/SolverProblemsException.php -use std::cell::RefCell; -use std::rc::Rc; - -use shirabe_php_shim::RuntimeException; - use crate::dependency_resolver::Pool; use crate::dependency_resolver::Problem; use crate::dependency_resolver::Request; use crate::dependency_resolver::Rule; use crate::repository::RepositorySet; use crate::util::IniHelper; +use shirabe_php_shim::RuntimeException; +use std::cell::RefCell; +use std::rc::Rc; #[derive(Debug)] pub struct SolverProblemsException { diff --git a/crates/shirabe/src/dependency_resolver/transaction.rs b/crates/shirabe/src/dependency_resolver/transaction.rs index 9e0a709..07564ed 100644 --- a/crates/shirabe/src/dependency_resolver/transaction.rs +++ b/crates/shirabe/src/dependency_resolver/transaction.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/DependencyResolver/Transaction.php -use indexmap::IndexMap; -use indexmap::IndexSet; -use shirabe_php_shim::{ - PhpMixed, array_filter, array_intersect, array_keys, array_pop, array_unshift, strcmp, uasort, - uasort_map, -}; - use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::MarkAliasInstalledOperation; use crate::dependency_resolver::operation::MarkAliasUninstalledOperation; @@ -17,6 +10,12 @@ use crate::package::AliasPackageHandle; use crate::package::Link; use crate::package::PackageInterfaceHandle; use crate::repository::PlatformRepository; +use indexmap::IndexMap; +use indexmap::IndexSet; +use shirabe_php_shim::{ + PhpMixed, array_filter, array_intersect, array_keys, array_pop, array_unshift, strcmp, uasort, + uasort_map, +}; /// @internal #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/downloader/mod.rs b/crates/shirabe/src/downloader.rs index 4f7641b..4f7641b 100644 --- a/crates/shirabe/src/downloader/mod.rs +++ b/crates/shirabe/src/downloader.rs diff --git a/crates/shirabe/src/downloader/archive_downloader.rs b/crates/shirabe/src/downloader/archive_downloader.rs index b1bdee7..4744bc2 100644 --- a/crates/shirabe/src/downloader/archive_downloader.rs +++ b/crates/shirabe/src/downloader/archive_downloader.rs @@ -1,5 +1,12 @@ //! ref: composer/src/Composer/Downloader/ArchiveDownloader.php +use crate::dependency_resolver::operation::InstallOperation; +use crate::downloader::DownloaderInterface; +use crate::downloader::FileDownloader; +use crate::io::IOInterfaceImmutable; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; +use crate::util::Platform; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::symfony::finder::Finder; @@ -9,14 +16,6 @@ use shirabe_php_shim::{ }; use std::path::{Path, PathBuf}; -use crate::dependency_resolver::operation::InstallOperation; -use crate::downloader::DownloaderInterface; -use crate::downloader::FileDownloader; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; -use crate::util::Platform; - pub trait ArchiveDownloader { fn inner(&self) -> &FileDownloader; fn inner_mut(&mut self) -> &mut FileDownloader; diff --git a/crates/shirabe/src/downloader/change_report_interface.rs b/crates/shirabe/src/downloader/change_report_interface.rs index 718b2c1..ca2a113 100644 --- a/crates/shirabe/src/downloader/change_report_interface.rs +++ b/crates/shirabe/src/downloader/change_report_interface.rs @@ -1,8 +1,7 @@ //! ref: composer/src/Composer/Downloader/ChangeReportInterface.php -use anyhow::Result; - use crate::package::PackageInterfaceHandle; +use anyhow::Result; pub trait ChangeReportInterface { fn get_local_changes( diff --git a/crates/shirabe/src/downloader/download_manager.rs b/crates/shirabe/src/downloader/download_manager.rs index b978368..82bf4bb 100644 --- a/crates/shirabe/src/downloader/download_manager.rs +++ b/crates/shirabe/src/downloader/download_manager.rs @@ -1,6 +1,12 @@ //! ref: composer/src/Composer/Downloader/DownloadManager.php +use crate::downloader::DownloaderInterface; +use crate::exception::IrrecoverableDownloadException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -10,13 +16,6 @@ use shirabe_php_shim::{ strtolower, usort, }; -use crate::downloader::DownloaderInterface; -use crate::exception::IrrecoverableDownloadException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; - /// Downloaders manager. #[derive(Debug)] pub struct DownloadManager { diff --git a/crates/shirabe/src/downloader/dvcs_downloader_interface.rs b/crates/shirabe/src/downloader/dvcs_downloader_interface.rs index 59f5774..e33aa46 100644 --- a/crates/shirabe/src/downloader/dvcs_downloader_interface.rs +++ b/crates/shirabe/src/downloader/dvcs_downloader_interface.rs @@ -1,8 +1,7 @@ //! ref: composer/src/Composer/Downloader/DvcsDownloaderInterface.php -use anyhow::Result; - use crate::package::PackageInterfaceHandle; +use anyhow::Result; pub trait DvcsDownloaderInterface { fn get_unpushed_changes( diff --git a/crates/shirabe/src/downloader/file_downloader.rs b/crates/shirabe/src/downloader/file_downloader.rs index 66f3390..d3e1f6c 100644 --- a/crates/shirabe/src/downloader/file_downloader.rs +++ b/crates/shirabe/src/downloader/file_downloader.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Downloader/FileDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - -use crate::util::Silencer; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, - PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists, - filesize, get_class, hash, hash_file, in_array, is_dir, is_executable, parse_url, pathinfo, - realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, -}; - use crate::cache::Cache; use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; @@ -27,13 +14,24 @@ use crate::exception::IrrecoverableDownloadException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; use crate::io::NullIO; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::comparer::Comparer; use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; +use crate::util::Silencer; use crate::util::Url as UrlUtil; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, InvalidArgumentException, PATHINFO_BASENAME, PATHINFO_EXTENSION, + PHP_URL_PATH, PhpMixed, RuntimeException, UnexpectedValueException, array_search, file_exists, + filesize, get_class, hash, hash_file, in_array, is_dir, is_executable, parse_url, pathinfo, + realpath, rtrim, spl_object_hash, strlen, strpos, strtr, trim, umask, usleep, +}; +use std::sync::{LazyLock, Mutex}; /// @var array<string, int|string> /// @private diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index fd044f8..dc27e0c 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Downloader/GitDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir, - preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::ChangeReportInterface; @@ -18,12 +9,20 @@ use crate::downloader::VcsDownloader; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::util::Filesystem; use crate::util::Git as GitUtil; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_map, basename, dirname, implode, in_array, is_dir, + preg_quote, realpath, rtrim, strlen, strpos, substr, trim, version_compare, +}; #[derive(Debug)] pub struct GitDownloader { diff --git a/crates/shirabe/src/downloader/path_downloader.rs b/crates/shirabe/src/downloader/path_downloader.rs index 694f758..cfd4889 100644 --- a/crates/shirabe/src/downloader/path_downloader.rs +++ b/crates/shirabe/src/downloader/path_downloader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Downloader/PathDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, - RuntimeException, file_exists, function_exists, is_dir, realpath, -}; - use crate::cache::Cache; use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; @@ -19,6 +10,7 @@ use crate::downloader::VcsCapableDownloaderInterface; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::archiver::ArchivableFilesFinder; use crate::package::dumper::ArrayDumper; @@ -28,6 +20,13 @@ use crate::util::Filesystem; use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::filesystem::Filesystem as SymfonyFilesystem; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, PHP_WINDOWS_VERSION_MAJOR, PHP_WINDOWS_VERSION_MINOR, PhpMixed, + RuntimeException, file_exists, function_exists, is_dir, realpath, +}; #[derive(Debug)] pub struct PathDownloader { diff --git a/crates/shirabe/src/downloader/svn_downloader.rs b/crates/shirabe/src/downloader/svn_downloader.rs index 8c13a05..cd48dae 100644 --- a/crates/shirabe/src/downloader/svn_downloader.rs +++ b/crates/shirabe/src/downloader/svn_downloader.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Downloader/SvnDownloader.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, RuntimeException, is_dir, version_compare}; - use crate::config::Config; use crate::downloader::ChangeReportInterface; use crate::downloader::DownloaderInterface; @@ -13,11 +8,15 @@ use crate::downloader::VcsDownloader; use crate::downloader::VcsDownloaderBase; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::repository::VcsRepository; use crate::util::Filesystem; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, RuntimeException, is_dir, version_compare}; #[derive(Debug)] pub struct SvnDownloader { diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 8084c37..1c89571 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Downloader/VcsDownloader.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, explode, - get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr, trim, -}; - use crate::config::Config; use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::UninstallOperation; @@ -17,12 +9,19 @@ use crate::downloader::DownloaderInterface; use crate::downloader::VcsCapableDownloaderInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::dumper::ArrayDumper; use crate::package::version::VersionGuesser; use crate::package::version::VersionParser; use crate::util::Filesystem; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_map, array_shift, explode, + get_class_err, implode, rawurldecode, realpath, str_replace, strlen, strpos, substr, trim, +}; #[derive(Debug)] pub struct VcsDownloaderBase { diff --git a/crates/shirabe/src/event_dispatcher/mod.rs b/crates/shirabe/src/event_dispatcher.rs index a50fa4d..a50fa4d 100644 --- a/crates/shirabe/src/event_dispatcher/mod.rs +++ b/crates/shirabe/src/event_dispatcher.rs diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs index 091160e..87552a9 100644 --- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs +++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs @@ -1,19 +1,5 @@ //! ref: composer/src/Composer/EventDispatcher/EventDispatcher.php -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::symfony::process::ExecutableFinder; -use shirabe_external_packages::symfony::process::PhpExecutableFinder; -use shirabe_php_shim::{ - InvalidArgumentException, PATH_SEPARATOR, PhpMixed, RuntimeException, array_pop, array_push, - array_search_in_vec, array_splice, class_exists, defined, file_exists, get_class, hash, - implode, ini_get, is_a, is_array, is_callable, is_object, is_string, krsort, preg_quote, - realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, - spl_object_hash, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, - strtoupper, substr, trim, -}; - use crate::autoload::ClassLoader; use crate::composer::PartialComposerHandle; use crate::composer::PartialComposerWeakHandle; @@ -32,6 +18,18 @@ use crate::repository::RepositoryInterface; use crate::script::Event as ScriptEvent; use crate::util::Platform; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::symfony::process::ExecutableFinder; +use shirabe_external_packages::symfony::process::PhpExecutableFinder; +use shirabe_php_shim::{ + InvalidArgumentException, PATH_SEPARATOR, PhpMixed, RuntimeException, array_pop, array_push, + array_search_in_vec, array_splice, class_exists, defined, file_exists, get_class, hash, + implode, ini_get, is_a, is_array, is_callable, is_object, is_string, krsort, preg_quote, + realpath, spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, + spl_object_hash, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, + strtoupper, substr, trim, +}; /// Represents a callable listener. PHP's `callable` may be a string (command, script, or /// "Class::method"), a `[object|string, method]` pair, or a `\Closure`. @@ -858,7 +856,7 @@ impl EventDispatcher { ) -> anyhow::Result<PhpMixed> { if self.io.is_verbose() { self.io.write_error3( - &format!("> {}: {}::{}", event.get_name(), class_name, method_name,), + &format!("> {}: {}::{}", event.get_name(), class_name, method_name), true, crate::io::NORMAL, ); @@ -1218,8 +1216,6 @@ impl EventDispatcher { Ok(()) } - // ---- helpers ---- - fn io_clone(&self) -> std::rc::Rc<std::cell::RefCell<dyn IOInterface>> { self.io.clone() } diff --git a/crates/shirabe/src/exception/mod.rs b/crates/shirabe/src/exception.rs index 0355e35..0355e35 100644 --- a/crates/shirabe/src/exception/mod.rs +++ b/crates/shirabe/src/exception.rs diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs index 6d1729b..b3d478c 100644 --- a/crates/shirabe/src/factory.rs +++ b/crates/shirabe/src/factory.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Factory.php -use indexmap::IndexMap; - -use shirabe_external_packages::symfony::console::formatter::OutputFormatter; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; -use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface; -use shirabe_external_packages::symfony::console::output::ConsoleOutput; -use shirabe_php_shim::{ - InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException, - UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded, - file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode, - mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, -}; - use crate::autoload::AutoloadGenerator; use crate::cache::Cache; use crate::composer::{ComposerHandle, ComposerWeakHandle, PartialOrFullComposer}; @@ -64,6 +51,17 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Silencer; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::symfony::console::formatter::OutputFormatter; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyle; +use shirabe_external_packages::symfony::console::formatter::OutputFormatterStyleInterface; +use shirabe_external_packages::symfony::console::output::ConsoleOutput; +use shirabe_php_shim::{ + InvalidArgumentException, PATHINFO_EXTENSION, PHP_EOL, PHP_OS, PhpMixed, RuntimeException, + UnexpectedValueException, array_replace_recursive, class_exists, dirname, extension_loaded, + file_exists, file_get_contents, file_put_contents, implode, is_dir, is_file, json_decode, + mkdir, pathinfo, realpath, rename, rtrim, strpos, strtr, substr, trim, +}; /// Either a configuration array or a filename to read from. PHP's `$localConfig` accepts both. pub enum LocalConfigInput { diff --git a/crates/shirabe/src/filter/mod.rs b/crates/shirabe/src/filter.rs index a5f35c5..a5f35c5 100644 --- a/crates/shirabe/src/filter/mod.rs +++ b/crates/shirabe/src/filter.rs diff --git a/crates/shirabe/src/filter/platform_requirement_filter/mod.rs b/crates/shirabe/src/filter/platform_requirement_filter.rs index 0a6556f..0a6556f 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/mod.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter.rs diff --git a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs index 854a4f6..709fdfc 100644 --- a/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs +++ b/crates/shirabe/src/filter/platform_requirement_filter/ignore_list_platform_requirement_filter.rs @@ -1,5 +1,8 @@ //! ref: composer/src/Composer/Filter/PlatformRequirementFilter/IgnoreListPlatformRequirementFilter.php +use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; +use crate::package::base_package::{self}; +use crate::repository::PlatformRepository; use shirabe_external_packages::composer::pcre::Preg; use shirabe_semver::Interval; use shirabe_semver::Intervals; @@ -8,10 +11,6 @@ use shirabe_semver::constraint::MatchAllConstraint; use shirabe_semver::constraint::MultiConstraint; use shirabe_semver::constraint::SimpleConstraint; -use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; -use crate::package::base_package::{self}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct IgnoreListPlatformRequirementFilter { ignore_regex: String, diff --git a/crates/shirabe/src/installed_versions.rs b/crates/shirabe/src/installed_versions.rs index 0e22e06..8b287f1 100644 --- a/crates/shirabe/src/installed_versions.rs +++ b/crates/shirabe/src/installed_versions.rs @@ -1,7 +1,6 @@ //! ref: composer/src/Composer/InstalledVersions.php -use std::sync::Mutex; - +use crate::autoload::ClassLoader; use anyhow::Result; use indexmap::IndexMap; use shirabe_php_shim::{ @@ -9,8 +8,7 @@ use shirabe_php_shim::{ implode, is_file, method_exists, php_dir, require_php_file, strtr_array, substr, }; use shirabe_semver::VersionParser; - -use crate::autoload::ClassLoader; +use std::sync::Mutex; /// This class is copied in every Composer installed project and available to all /// diff --git a/crates/shirabe/src/installer/binary_installer.rs b/crates/shirabe/src/installer/binary_installer.rs index ea73f6f..31e2e7b 100644 --- a/crates/shirabe/src/installer/binary_installer.rs +++ b/crates/shirabe/src/installer/binary_installer.rs @@ -1,6 +1,13 @@ //! ref: composer/src/Composer/Installer/BinaryInstaller.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::package::PackageInterfaceHandle; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ @@ -9,14 +16,6 @@ use shirabe_php_shim::{ substr, trim, umask, }; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::package::PackageInterfaceHandle; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - /// Seam over the BinaryInstaller methods reached through LibraryInstaller, so tests can inject a /// recording double. Composer has no PHP `BinaryInstallerInterface`; this exists only to allow the /// `LibraryInstaller` collaborator to be mocked the way PHPUnit mocks the concrete class. diff --git a/crates/shirabe/src/installer/installation_manager.rs b/crates/shirabe/src/installer/installation_manager.rs index bee14cc..3ce8076 100644 --- a/crates/shirabe/src/installer/installation_manager.rs +++ b/crates/shirabe/src/installer/installation_manager.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Installer/InstallationManager.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::seld::signal::SignalHandler; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, array_splice, array_unshift, http_build_query, json_encode, - str_contains, str_replace, strpos, strtolower, -}; - use crate::dependency_resolver::operation::InstallOperation; use crate::dependency_resolver::operation::MarkAliasInstalledOperation; use crate::dependency_resolver::operation::MarkAliasUninstalledOperation; @@ -21,10 +12,18 @@ use crate::installer::InstallerInterface; use crate::installer::PackageEvents; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::repository::InstalledRepositoryInterface; use crate::util::Platform; use crate::util::r#loop::Loop; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::seld::signal::SignalHandler; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, array_splice, array_unshift, http_build_query, json_encode, + str_contains, str_replace, strpos, strtolower, +}; /// Package operation manager. #[derive(Debug)] diff --git a/crates/shirabe/src/installer/installer_event.rs b/crates/shirabe/src/installer/installer_event.rs index ca0be22..5171b6d 100644 --- a/crates/shirabe/src/installer/installer_event.rs +++ b/crates/shirabe/src/installer/installer_event.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Installer/InstallerEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::composer::ComposerWeakHandle; use crate::dependency_resolver::Transaction; use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::io::IOInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct InstallerEvent { diff --git a/crates/shirabe/src/installer/library_installer.rs b/crates/shirabe/src/installer/library_installer.rs index 26fbf0e..133ba7c 100644 --- a/crates/shirabe/src/installer/library_installer.rs +++ b/crates/shirabe/src/installer/library_installer.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Installer/LibraryInstaller.php -use anyhow::Result; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, dirname, is_dir, is_link, preg_quote, - realpath, rmdir, rtrim, strpos, -}; - use crate::composer::PartialComposerWeakHandle; use crate::downloader::DownloadManagerInterface; use crate::installer::BinaryInstaller; @@ -19,6 +12,12 @@ use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; use crate::util::Platform; use crate::util::Silencer; +use anyhow::Result; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, dirname, is_dir, is_link, preg_quote, + realpath, rmdir, rtrim, strpos, +}; /// Package installation manager. #[derive(Debug)] diff --git a/crates/shirabe/src/io/mod.rs b/crates/shirabe/src/io.rs index f7c8ad1..f7c8ad1 100644 --- a/crates/shirabe/src/io/mod.rs +++ b/crates/shirabe/src/io.rs diff --git a/crates/shirabe/src/io/console_io.rs b/crates/shirabe/src/io/console_io.rs index d14d730..210dbdc 100644 --- a/crates/shirabe/src/io/console_io.rs +++ b/crates/shirabe/src/io/console_io.rs @@ -1,7 +1,13 @@ //! ref: composer/src/Composer/IO/ConsoleIO.php use crate::config::Config; +use crate::io::BaseIO; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::io::IOInterfaceMutable; use crate::io::io_interface; +use crate::question::StrictConfirmationQuestion; +use crate::util::Silencer; use indexmap::IndexMap; use indexmap::indexmap; use shirabe_external_packages::composer::pcre::Preg; @@ -12,7 +18,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface; use shirabe_external_packages::symfony::console::output::ConsoleOutput; use shirabe_external_packages::symfony::console::output::ConsoleOutputInterface; use shirabe_external_packages::symfony::console::output::output_interface::{ - self as output_interface, OutputInterface, + self, OutputInterface, }; use shirabe_external_packages::symfony::console::question::ChoiceQuestion; use shirabe_external_packages::symfony::console::question::Question; @@ -23,13 +29,6 @@ use shirabe_php_shim::{ }; use std::cell::RefCell; -use crate::io::BaseIO; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::io::IOInterfaceMutable; -use crate::question::StrictConfirmationQuestion; -use crate::util::Silencer; - /// The Input/Output helper. #[derive(Debug)] pub struct ConsoleIO { diff --git a/crates/shirabe/src/json/mod.rs b/crates/shirabe/src/json.rs index e5c3406..e5c3406 100644 --- a/crates/shirabe/src/json/mod.rs +++ b/crates/shirabe/src/json.rs diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index b38de1e..c0b8816 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -1,6 +1,12 @@ //! ref: composer/src/Composer/Json/JsonFile.php +use crate::downloader::TransportException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::json::JsonValidationException; +use crate::util::Filesystem; +use crate::util::HttpDownloader; use crate::util::Silencer; use anyhow::Result; use indexmap::IndexMap; @@ -14,13 +20,6 @@ use shirabe_php_shim::{ str_ends_with, str_repeat, strlen, strpos, usleep, }; -use crate::downloader::TransportException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::json::JsonValidationException; -use crate::util::Filesystem; -use crate::util::HttpDownloader; - #[derive(Debug, Clone)] pub struct JsonEncodeOptions { pub unescaped_slashes: bool, diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs index c62e31e..043534d 100644 --- a/crates/shirabe/src/json/json_manipulator.rs +++ b/crates/shirabe/src/json/json_manipulator.rs @@ -1,7 +1,9 @@ //! ref: composer/src/Composer/Json/JsonManipulator.php +use crate::json::JsonFile; +use crate::json::json_grammar::{self, ValueKind}; +use crate::repository::PlatformRepository; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::{ InvalidArgumentException, LogicException, PhpMixed, addcslashes, array_key_exists, array_keys, @@ -10,10 +12,6 @@ use shirabe_php_shim::{ trim, uksort, }; -use crate::json::JsonFile; -use crate::json::json_grammar::{self, ValueKind}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct JsonManipulator { contents: String, diff --git a/crates/shirabe/src/package/mod.rs b/crates/shirabe/src/package.rs index 912ac17..912ac17 100644 --- a/crates/shirabe/src/package/mod.rs +++ b/crates/shirabe/src/package.rs diff --git a/crates/shirabe/src/package/alias_package.rs b/crates/shirabe/src/package/alias_package.rs index 5af61b2..79204df 100644 --- a/crates/shirabe/src/package/alias_package.rs +++ b/crates/shirabe/src/package/alias_package.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Package/AliasPackage.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::{PhpMixed, in_array}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::BasePackage; use crate::package::Link; use crate::package::Mirror; @@ -12,6 +7,10 @@ use crate::package::PackageHandle; use crate::package::PackageInterface; use crate::package::version::VersionParser; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::{PhpMixed, in_array}; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] pub struct AliasPackage { diff --git a/crates/shirabe/src/package/archiver/mod.rs b/crates/shirabe/src/package/archiver.rs index b4df5b0..b4df5b0 100644 --- a/crates/shirabe/src/package/archiver/mod.rs +++ b/crates/shirabe/src/package/archiver.rs diff --git a/crates/shirabe/src/package/archiver/archive_manager.rs b/crates/shirabe/src/package/archiver/archive_manager.rs index be911d6..eaeab9c 100644 --- a/crates/shirabe/src/package/archiver/archive_manager.rs +++ b/crates/shirabe/src/package/archiver/archive_manager.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Package/Archiver/ArchiveManager.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, RuntimeException, bin2hex, file_exists, random_bytes, realpath, - sys_get_temp_dir, -}; - use crate::downloader::DownloadManager; use crate::json::JsonFile; use crate::package::CompletePackageInterfaceHandle; @@ -16,6 +9,12 @@ use crate::package::archiver::ZipArchiver; use crate::util::Filesystem; use crate::util::SyncHelper; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, RuntimeException, bin2hex, file_exists, random_bytes, realpath, + sys_get_temp_dir, +}; pub struct ArchiveManager { pub(crate) download_manager: std::rc::Rc<std::cell::RefCell<DownloadManager>>, diff --git a/crates/shirabe/src/package/archiver/phar_archiver.rs b/crates/shirabe/src/package/archiver/phar_archiver.rs index c25b90b..1bac060 100644 --- a/crates/shirabe/src/package/archiver/phar_archiver.rs +++ b/crates/shirabe/src/package/archiver/phar_archiver.rs @@ -1,15 +1,14 @@ //! ref: composer/src/Composer/Package/Archiver/PharArchiver.php +use crate::package::archiver::ArchivableFilesFilter; +use crate::package::archiver::ArchivableFilesFinder; +use crate::package::archiver::ArchiverInterface; use indexmap::IndexMap; use shirabe_php_shim::{ FilesystemIterator, Phar, PharData, PhpMixed, RuntimeException, bzcompress, file_exists, file_put_contents, function_exists, gzcompress, pack, str_repeat, strrpos, unlink, }; -use crate::package::archiver::ArchivableFilesFilter; -use crate::package::archiver::ArchivableFilesFinder; -use crate::package::archiver::ArchiverInterface; - fn formats() -> IndexMap<&'static str, i64> { let mut m = IndexMap::new(); m.insert("zip", Phar::ZIP); diff --git a/crates/shirabe/src/package/base_package.rs b/crates/shirabe/src/package/base_package.rs index 60211d2..04b4ea0 100644 --- a/crates/shirabe/src/package/base_package.rs +++ b/crates/shirabe/src/package/base_package.rs @@ -1,15 +1,13 @@ //! ref: composer/src/Composer/Package/BasePackage.php -use std::sync::LazyLock; - -use indexmap::IndexMap; -use shirabe_php_shim::preg_quote; - use crate::package::DisplayMode; use crate::package::Link; use crate::package::PackageInterface; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterfaceHandle; +use indexmap::IndexMap; +use shirabe_php_shim::preg_quote; +use std::sync::LazyLock; pub struct SupportedLinkType { pub description: &'static str, diff --git a/crates/shirabe/src/package/comparer/mod.rs b/crates/shirabe/src/package/comparer.rs index 878d7e0..878d7e0 100644 --- a/crates/shirabe/src/package/comparer/mod.rs +++ b/crates/shirabe/src/package/comparer.rs diff --git a/crates/shirabe/src/package/comparer/comparer.rs b/crates/shirabe/src/package/comparer/comparer.rs index 3139295..b0e01bd 100644 --- a/crates/shirabe/src/package/comparer/comparer.rs +++ b/crates/shirabe/src/package/comparer/comparer.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Package/Comparer/Comparer.php +use crate::util::Platform; use indexmap::IndexMap; use std::path::Path; -use crate::util::Platform; - #[derive(Debug)] pub struct Comparer { source: String, diff --git a/crates/shirabe/src/package/complete_alias_package.rs b/crates/shirabe/src/package/complete_alias_package.rs index 2fff592..2172157 100644 --- a/crates/shirabe/src/package/complete_alias_package.rs +++ b/crates/shirabe/src/package/complete_alias_package.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Package/CompleteAliasPackage.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::AliasPackage; use crate::package::CompletePackageHandle; use crate::package::CompletePackageInterface; use crate::package::PackageHandle; use crate::package::handle::delegate_package_interface_to_inner; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct CompleteAliasPackage { diff --git a/crates/shirabe/src/package/complete_package_interface.rs b/crates/shirabe/src/package/complete_package_interface.rs index 42b35ef..948c5e6 100644 --- a/crates/shirabe/src/package/complete_package_interface.rs +++ b/crates/shirabe/src/package/complete_package_interface.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Package/CompletePackageInterface.php +use crate::package::PackageInterface; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use crate::package::PackageInterface; - pub trait CompletePackageInterface: PackageInterface { fn get_scripts(&self) -> IndexMap<String, Vec<String>>; diff --git a/crates/shirabe/src/package/dumper/mod.rs b/crates/shirabe/src/package/dumper.rs index c501aec..c501aec 100644 --- a/crates/shirabe/src/package/dumper/mod.rs +++ b/crates/shirabe/src/package/dumper.rs diff --git a/crates/shirabe/src/package/dumper/array_dumper.rs b/crates/shirabe/src/package/dumper/array_dumper.rs index ec33340..6688ad5 100644 --- a/crates/shirabe/src/package/dumper/array_dumper.rs +++ b/crates/shirabe/src/package/dumper/array_dumper.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/Package/Dumper/ArrayDumper.php -use indexmap::IndexMap; -use shirabe_php_shim::{DATE_RFC3339, PhpMixed}; - use crate::package::Mirror; use crate::package::PackageInterfaceHandle; use crate::package::SUPPORTED_LINK_TYPES; +use indexmap::IndexMap; +use shirabe_php_shim::{DATE_RFC3339, PhpMixed}; /// Serializes a Mirror back into the PHP array shape `{url, preferred}`. fn mirror_to_php(mirror: Mirror) -> PhpMixed { diff --git a/crates/shirabe/src/package/handle.rs b/crates/shirabe/src/package/handle.rs index 39121fa..28b1dbe 100644 --- a/crates/shirabe/src/package/handle.rs +++ b/crates/shirabe/src/package/handle.rs @@ -3,13 +3,12 @@ //! No weak handles are provided: an alias package never aliases another alias package, so the //! `alias_of` references are acyclic. -use std::cell::RefCell; -use std::rc::Rc; - use crate::package::{ AliasPackage, CompleteAliasPackage, CompletePackage, CompletePackageInterface, Package, PackageInterface, RootAliasPackage, RootPackage, RootPackageInterface, }; +use std::cell::RefCell; +use std::rc::Rc; /// Any package type. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/package/loader/mod.rs b/crates/shirabe/src/package/loader.rs index 1073172..1073172 100644 --- a/crates/shirabe/src/package/loader/mod.rs +++ b/crates/shirabe/src/package/loader.rs diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs index b86f1de..07ad11f 100644 --- a/crates/shirabe/src/package/loader/array_loader.rs +++ b/crates/shirabe/src/package/loader/array_loader.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Package/Loader/ArrayLoader.php -use anyhow::Result; -use chrono::Utc; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode, - ltrim, stripos, strpos, strtolower, strval, substr, trigger_error, trim, -}; - use crate::package::CompleteAliasPackageHandle; use crate::package::CompletePackage; use crate::package::CompletePackageHandle; @@ -24,6 +15,14 @@ use crate::package::RootPackageHandle; use crate::package::SUPPORTED_LINK_TYPES; use crate::package::loader::LoaderInterface; use crate::package::version::VersionParser; +use anyhow::Result; +use chrono::Utc; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode, + ltrim, stripos, strpos, strtolower, strval, substr, trigger_error, trim, +}; #[derive(Debug)] pub struct ArrayLoader { diff --git a/crates/shirabe/src/package/loader/root_package_loader.rs b/crates/shirabe/src/package/loader/root_package_loader.rs index c0101ac..83cda30 100644 --- a/crates/shirabe/src/package/loader/root_package_loader.rs +++ b/crates/shirabe/src/package/loader/root_package_loader.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Package/Loader/RootPackageLoader.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException, strtolower}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; @@ -18,6 +14,9 @@ use crate::repository::RepositoryFactory; use crate::repository::RepositoryManager; use crate::util::Platform; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, RuntimeException, UnexpectedValueException, strtolower}; #[derive(Debug)] pub struct RootPackageLoader { diff --git a/crates/shirabe/src/package/loader/validating_array_loader.rs b/crates/shirabe/src/package/loader/validating_array_loader.rs index 14500a6..56e4157 100644 --- a/crates/shirabe/src/package/loader/validating_array_loader.rs +++ b/crates/shirabe/src/package/loader/validating_array_loader.rs @@ -1,7 +1,11 @@ //! ref: composer/src/Composer/Package/Loader/ValidatingArrayLoader.php +use crate::package::loader::InvalidPackageException; +use crate::package::loader::LoaderInterface; +use crate::package::version::VersionParser; +use crate::package::{STABILITIES, SUPPORTED_LINK_TYPES}; +use crate::repository::PlatformRepository; use indexmap::IndexMap; - use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ E_USER_DEPRECATED, PHP_EOL, PhpMixed, array_intersect_key, array_values, filter_var_email, @@ -14,12 +18,6 @@ use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; use shirabe_spdx_licenses::SpdxLicenses; -use crate::package::loader::InvalidPackageException; -use crate::package::loader::LoaderInterface; -use crate::package::version::VersionParser; -use crate::package::{STABILITIES, SUPPORTED_LINK_TYPES}; -use crate::repository::PlatformRepository; - #[derive(Debug)] pub struct ValidatingArrayLoader { loader: Box<dyn LoaderInterface>, diff --git a/crates/shirabe/src/package/locker.rs b/crates/shirabe/src/package/locker.rs index 1f123f1..09c2def 100644 --- a/crates/shirabe/src/package/locker.rs +++ b/crates/shirabe/src/package/locker.rs @@ -1,16 +1,5 @@ //! ref: composer/src/Composer/Package/Locker.php -use anyhow::Result; -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::seld::json_lint::ParsingException; -use shirabe_php_shim::{ - DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, - array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, - ksort, realpath, strcmp, strtolower, touch2, trim, usort, -}; - use crate::installer::InstallationManager; use crate::io::IOInterface; use crate::json::JsonEncodeOptions; @@ -34,6 +23,15 @@ use crate::repository::RepositoryInterfaceHandle; use crate::repository::RootPackageRepository; use crate::util::Git as GitUtil; use crate::util::ProcessExecutor; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::seld::json_lint::ParsingException; +use shirabe_php_shim::{ + DATE_RFC3339, LogicException, PhpMixed, RuntimeException, array_intersect, array_keys, + array_map, array_merge, file_get_contents, filemtime, function_exists, hash, in_array, is_int, + ksort, realpath, strcmp, strtolower, touch2, trim, usort, +}; /// Reads/writes project lockfile (composer.lock). #[derive(Debug)] diff --git a/crates/shirabe/src/package/package.rs b/crates/shirabe/src/package/package.rs index 7fa9452..6eaf348 100644 --- a/crates/shirabe/src/package/package.rs +++ b/crates/shirabe/src/package/package.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Package/Package.php -use std::rc::Rc; - -use chrono::{DateTime, Utc}; -use indexmap::{IndexMap, IndexSet}; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{E_USER_DEPRECATED, LogicException, PhpMixed, strpos, trigger_error}; - use crate::package::BasePackage; use crate::package::DisplayMode; use crate::package::Link; @@ -16,6 +8,11 @@ use crate::package::version::VersionParser; use crate::repository::RepositoryInterfaceHandle; use crate::repository::RepositoryInterfaceWeakHandle; use crate::util::ComposerMirror; +use chrono::{DateTime, Utc}; +use indexmap::{IndexMap, IndexSet}; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{E_USER_DEPRECATED, LogicException, PhpMixed, strpos, trigger_error}; +use std::rc::Rc; /// Mirror entry, e.g. `['url' => 'https://...', 'preferred' => true]`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/package/package_interface.rs b/crates/shirabe/src/package/package_interface.rs index 42a2ca2..8c9213c 100644 --- a/crates/shirabe/src/package/package_interface.rs +++ b/crates/shirabe/src/package/package_interface.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/Package/PackageInterface.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::Link; use crate::package::Mirror; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; /// Selects how `get_full_pretty_version` renders the reference. /// diff --git a/crates/shirabe/src/package/root_alias_package.rs b/crates/shirabe/src/package/root_alias_package.rs index 687ee59..41b30a9 100644 --- a/crates/shirabe/src/package/root_alias_package.rs +++ b/crates/shirabe/src/package/root_alias_package.rs @@ -1,8 +1,5 @@ //! ref: composer/src/Composer/Package/RootAliasPackage.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::CompleteAliasPackage; use crate::package::CompletePackageHandle; use crate::package::CompletePackageInterface; @@ -10,6 +7,8 @@ use crate::package::Link; use crate::package::RootPackageHandle; use crate::package::RootPackageInterface; use crate::package::handle::delegate_package_interface_to_inner; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct RootAliasPackage { diff --git a/crates/shirabe/src/package/root_package.rs b/crates/shirabe/src/package/root_package.rs index 3ec7cbd..d764f9e 100644 --- a/crates/shirabe/src/package/root_package.rs +++ b/crates/shirabe/src/package/root_package.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Package/RootPackage.php -use chrono::{DateTime, Utc}; -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::package::CompletePackage; use crate::package::CompletePackageInterface; use crate::package::DisplayMode; @@ -12,6 +8,9 @@ use crate::package::Mirror; use crate::package::PackageInterface; use crate::package::RootPackageInterface; use crate::repository::RepositoryInterfaceHandle; +use chrono::{DateTime, Utc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug, Clone)] pub struct RootPackage { diff --git a/crates/shirabe/src/package/root_package_interface.rs b/crates/shirabe/src/package/root_package_interface.rs index d597555..85e5f9a 100644 --- a/crates/shirabe/src/package/root_package_interface.rs +++ b/crates/shirabe/src/package/root_package_interface.rs @@ -1,12 +1,10 @@ //! ref: composer/src/Composer/Package/RootPackageInterface.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - -use crate::package::PackageInterface; - use crate::package::CompletePackageInterface; use crate::package::Link; +use crate::package::PackageInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; pub trait RootPackageInterface: CompletePackageInterface { fn get_aliases(&self) -> &[IndexMap<String, String>]; diff --git a/crates/shirabe/src/package/version/mod.rs b/crates/shirabe/src/package/version.rs index b2f32a2..b2f32a2 100644 --- a/crates/shirabe/src/package/version/mod.rs +++ b/crates/shirabe/src/package/version.rs diff --git a/crates/shirabe/src/package/version/version_guesser.rs b/crates/shirabe/src/package/version/version_guesser.rs index 6642201..f18f363 100644 --- a/crates/shirabe/src/package/version/version_guesser.rs +++ b/crates/shirabe/src/package/version/version_guesser.rs @@ -1,14 +1,5 @@ //! ref: composer/src/Composer/Package/Version/VersionGuesser.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PHP_INT_MAX, PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty, - function_exists, implode, is_string, json_encode, preg_quote, str_replace, strlen, - strnatcasecmp, strpos, substr, trim, usort, -}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::NullIO; @@ -19,6 +10,14 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PHP_INT_MAX, PhpMixed, RuntimeException, array_keys, array_map, array_merge, empty, + function_exists, implode, is_string, json_encode, preg_quote, str_replace, strlen, + strnatcasecmp, strpos, substr, trim, usort, +}; /// Seam over the parts of [`VersionGuesser`] that consumers depend on, so they can be exercised /// with a test double. PHP has no such interface; this exists only to allow mocking the concrete diff --git a/crates/shirabe/src/package/version/version_parser.rs b/crates/shirabe/src/package/version/version_parser.rs index d412d47..3527722 100644 --- a/crates/shirabe/src/package/version/version_parser.rs +++ b/crates/shirabe/src/package/version/version_parser.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/Package/Version/VersionParser.php +use crate::repository::PlatformRepository; use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_external_packages::composer::pcre::Preg; use shirabe_semver::Semver; use shirabe_semver::VersionParser as SemverVersionParser; use shirabe_semver::constraint::AnyConstraint; - -use crate::repository::PlatformRepository; +use std::sync::{LazyLock, Mutex}; static CONSTRAINTS: LazyLock<Mutex<IndexMap<String, AnyConstraint>>> = LazyLock::new(|| Mutex::new(IndexMap::new())); diff --git a/crates/shirabe/src/package/version/version_selector.rs b/crates/shirabe/src/package/version/version_selector.rs index 8a0d037..48b045e 100644 --- a/crates/shirabe/src/package/version/version_selector.rs +++ b/crates/shirabe/src/package/version/version_selector.rs @@ -1,21 +1,12 @@ //! ref: composer/src/Composer/Package/Version/VersionSelector.php -use crate::io::io_interface; - -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, strtolower, version_compare, -}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::filter::platform_requirement_filter::IgnoreAllPlatformRequirementFilter; use crate::filter::platform_requirement_filter::IgnoreListPlatformRequirementFilter; use crate::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use crate::filter::platform_requirement_filter::PlatformRequirementFilterInterface; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::PackageInterfaceHandle; use crate::package::base_package; use crate::package::dumper::ArrayDumper; @@ -24,6 +15,13 @@ use crate::package::version::VersionParser; use crate::repository::PlatformRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositorySetInterface; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION, strtolower, version_compare, +}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct VersionSelector { diff --git a/crates/shirabe/src/phpstan/mod.rs b/crates/shirabe/src/phpstan.rs index 5c48ac7..5c48ac7 100644 --- a/crates/shirabe/src/phpstan/mod.rs +++ b/crates/shirabe/src/phpstan.rs diff --git a/crates/shirabe/src/platform/mod.rs b/crates/shirabe/src/platform.rs index 6abbb76..6abbb76 100644 --- a/crates/shirabe/src/platform/mod.rs +++ b/crates/shirabe/src/platform.rs diff --git a/crates/shirabe/src/plugin/mod.rs b/crates/shirabe/src/plugin.rs index a26e117..a26e117 100644 --- a/crates/shirabe/src/plugin/mod.rs +++ b/crates/shirabe/src/plugin.rs diff --git a/crates/shirabe/src/plugin/capability/mod.rs b/crates/shirabe/src/plugin/capability.rs index 5b7dcea..5b7dcea 100644 --- a/crates/shirabe/src/plugin/capability/mod.rs +++ b/crates/shirabe/src/plugin/capability.rs diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index a949c03..dd68d1e 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -4,15 +4,6 @@ //! and is not implemented in Phase A. The structure is mirrored verbatim so //! future plugin support can fill in the runtime hooks. -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, array_key_exists, - get_class_obj, implode, ksort, trigger_error, trim, var_export_str, version_compare, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer::PartialComposerHandle; use crate::composer::{ComposerHandle, ComposerWeakHandle}; use crate::factory::DisablePlugins; @@ -31,6 +22,13 @@ use crate::repository::InstalledRepository; use crate::repository::RepositoryInterface; use crate::repository::RepositoryUtils; use crate::util::PackageSorter; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + E_USER_DEPRECATED, PhpMixed, RuntimeException, UnexpectedValueException, array_key_exists, + get_class_obj, implode, ksort, trigger_error, trim, var_export_str, version_compare, +}; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub struct PluginManager { diff --git a/crates/shirabe/src/plugin/post_file_download_event.rs b/crates/shirabe/src/plugin/post_file_download_event.rs index 9ba946e..88fc181 100644 --- a/crates/shirabe/src/plugin/post_file_download_event.rs +++ b/crates/shirabe/src/plugin/post_file_download_event.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Plugin/PostFileDownloadEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PostFileDownloadEvent { diff --git a/crates/shirabe/src/plugin/pre_file_download_event.rs b/crates/shirabe/src/plugin/pre_file_download_event.rs index 0cd14d7..9ec74a0 100644 --- a/crates/shirabe/src/plugin/pre_file_download_event.rs +++ b/crates/shirabe/src/plugin/pre_file_download_event.rs @@ -1,11 +1,10 @@ //! ref: composer/src/Composer/Plugin/PreFileDownloadEvent.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::util::HttpDownloader; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PreFileDownloadEvent { diff --git a/crates/shirabe/src/plugin/pre_pool_create_event.rs b/crates/shirabe/src/plugin/pre_pool_create_event.rs index 303159a..0ffde94 100644 --- a/crates/shirabe/src/plugin/pre_pool_create_event.rs +++ b/crates/shirabe/src/plugin/pre_pool_create_event.rs @@ -1,14 +1,12 @@ //! ref: composer/src/Composer/Plugin/PrePoolCreateEvent.php -use indexmap::IndexMap; - -use shirabe_php_shim::PhpMixed; - use crate::dependency_resolver::Request; use crate::event_dispatcher::Event; use crate::event_dispatcher::EventInterface; use crate::package::BasePackageHandle; use crate::repository::RepositoryInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; #[derive(Debug)] pub struct PrePoolCreateEvent { diff --git a/crates/shirabe/src/question/mod.rs b/crates/shirabe/src/question.rs index 4fedd84..4fedd84 100644 --- a/crates/shirabe/src/question/mod.rs +++ b/crates/shirabe/src/question.rs diff --git a/crates/shirabe/src/repository/mod.rs b/crates/shirabe/src/repository.rs index 478eedd..478eedd 100644 --- a/crates/shirabe/src/repository/mod.rs +++ b/crates/shirabe/src/repository.rs diff --git a/crates/shirabe/src/repository/array_repository.rs b/crates/shirabe/src/repository/array_repository.rs index afe2cc5..eec49f2 100644 --- a/crates/shirabe/src/repository/array_repository.rs +++ b/crates/shirabe/src/repository/array_repository.rs @@ -1,15 +1,5 @@ //! ref: composer/src/Composer/Repository/ArrayRepository.php -use std::cell::RefCell; -use std::rc::Weak; - -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{implode, preg_quote, strtolower}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::AliasPackageHandle; use crate::package::BasePackageHandle; use crate::package::CompleteAliasPackageHandle; @@ -21,6 +11,14 @@ use crate::repository::{ AbandonedInfo, FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, RepositoryInterfaceWeakHandle, SearchResult, }; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{implode, preg_quote, strtolower}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::SimpleConstraint; +use std::cell::RefCell; +use std::rc::Weak; /// A repository implementation that simply stores packages in an array #[derive(Debug)] diff --git a/crates/shirabe/src/repository/artifact_repository.rs b/crates/shirabe/src/repository/artifact_repository.rs index ac83e6b..7d9c02b 100644 --- a/crates/shirabe/src/repository/artifact_repository.rs +++ b/crates/shirabe/src/repository/artifact_repository.rs @@ -1,15 +1,8 @@ //! ref: composer/src/Composer/Repository/ArtifactRepository.php -use crate::io::io_interface; -use std::path::Path; - -use indexmap::IndexMap; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, UnexpectedValueException, extension_loaded, hash_file, -}; - use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; @@ -24,7 +17,12 @@ use crate::repository::{ use crate::util::Platform; use crate::util::Tar; use crate::util::Zip; +use indexmap::IndexMap; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, UnexpectedValueException, extension_loaded, hash_file, +}; use shirabe_semver::constraint::AnyConstraint; +use std::path::Path; pub struct ArtifactRepository { inner: ArrayRepository, diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 4042a9b..e3a5711 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -1,19 +1,5 @@ //! ref: composer/src/Composer/Repository/ComposerRepository.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_metadata_minifier::MetadataMinifier; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, - UnexpectedValueException, extension_loaded, hash, http_build_query, in_array, json_decode, - parse_url_all, realpath, strtolower, strtr, urlencode, var_export, -}; - -use shirabe_semver::CompilingMatcher; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::advisory::{AnySecurityAdvisory, PartialSecurityAdvisory}; use crate::cache::Cache; use crate::config::Config; @@ -46,6 +32,18 @@ use crate::util::HttpDownloader; use crate::util::Url; use crate::util::http::Response; use crate::util::r#loop::Loop; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_metadata_minifier::MetadataMinifier; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException, + UnexpectedValueException, extension_loaded, hash, http_build_query, in_array, json_decode, + parse_url_all, realpath, strtolower, strtr, urlencode, var_export, +}; +use shirabe_semver::CompilingMatcher; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug)] pub enum RootData { diff --git a/crates/shirabe/src/repository/composite_repository.rs b/crates/shirabe/src/repository/composite_repository.rs index d1456b1..9e5c975 100644 --- a/crates/shirabe/src/repository/composite_repository.rs +++ b/crates/shirabe/src/repository/composite_repository.rs @@ -1,14 +1,13 @@ //! ref: composer/src/Composer/Repository/CompositeRepository.php -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct CompositeRepository { @@ -147,7 +146,7 @@ impl RepositoryInterface for CompositeRepository { all_names_found.extend(result.names_found); } - let mut seen = std::collections::HashSet::new(); + let mut seen = indexmap::IndexSet::new(); let unique_names: Vec<String> = all_names_found .into_iter() .filter(|s| seen.insert(s.clone())) diff --git a/crates/shirabe/src/repository/filesystem_repository.rs b/crates/shirabe/src/repository/filesystem_repository.rs index 14365f2..ebe7600 100644 --- a/crates/shirabe/src/repository/filesystem_repository.rs +++ b/crates/shirabe/src/repository/filesystem_repository.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Repository/FilesystemRepository.php -use std::any::Any; - -use crate::util::Silencer; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, - array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array, - is_array, is_null, is_string, ksort, realpath, str_repeat, trim, usort, var_export, -}; - use crate::config::is_php_integer_key; use crate::installed_versions::InstalledVersions; use crate::installer::InstallationManagerInterface; @@ -29,7 +17,17 @@ use crate::repository::WritableArrayRepository; use crate::repository::{FindPackageConstraint, LoadPackagesResult, ProviderInfo, SearchResult}; use crate::util::Filesystem; use crate::util::Platform; +use crate::util::Silencer; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + Exception, InvalidArgumentException, LogicException, PhpMixed, UnexpectedValueException, + array_flip, dirname, r#eval, file_get_contents, get_class_err, get_debug_type, in_array, + is_array, is_null, is_string, ksort, realpath, str_repeat, trim, usort, var_export, +}; use shirabe_semver::constraint::AnyConstraint; +use std::any::Any; /// Filesystem repository. #[derive(Debug)] diff --git a/crates/shirabe/src/repository/handle.rs b/crates/shirabe/src/repository/handle.rs index d0ad774..64cb5b7 100644 --- a/crates/shirabe/src/repository/handle.rs +++ b/crates/shirabe/src/repository/handle.rs @@ -1,17 +1,15 @@ //! Shared handle over `RepositoryInterface`. -use std::cell::{Ref, RefCell, RefMut}; -use std::rc::{Rc, Weak}; - -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, LockArrayRepository, PlatformRepository, ProviderInfo, RepositoryInterface, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; +use std::cell::{Ref, RefCell, RefMut}; +use std::rc::{Rc, Weak}; /// Shared reference to a repository. Corresponds to PHP `RepositoryInterface`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/repository/installed_array_repository.rs b/crates/shirabe/src/repository/installed_array_repository.rs index 6eff28f..ae0843d 100644 --- a/crates/shirabe/src/repository/installed_array_repository.rs +++ b/crates/shirabe/src/repository/installed_array_repository.rs @@ -1,8 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledArrayRepository.php -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::repository::AdvisoryProviderInterface; @@ -12,6 +9,8 @@ use crate::repository::WritableRepositoryInterface; use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult, }; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct InstalledArrayRepository { diff --git a/crates/shirabe/src/repository/installed_filesystem_repository.rs b/crates/shirabe/src/repository/installed_filesystem_repository.rs index fc92aff..3cd21eb 100644 --- a/crates/shirabe/src/repository/installed_filesystem_repository.rs +++ b/crates/shirabe/src/repository/installed_filesystem_repository.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledFilesystemRepository.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_semver::constraint::AnyConstraint; - use crate::json::JsonFile; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; @@ -16,6 +12,9 @@ use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, SearchResult, }; use crate::util::Filesystem; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct InstalledFilesystemRepository { diff --git a/crates/shirabe/src/repository/installed_repository.rs b/crates/shirabe/src/repository/installed_repository.rs index b17fb27..9ed8d4e 100644 --- a/crates/shirabe/src/repository/installed_repository.rs +++ b/crates/shirabe/src/repository/installed_repository.rs @@ -1,11 +1,5 @@ //! ref: composer/src/Composer/Repository/InstalledRepository.php -use indexmap::IndexMap; -use shirabe_php_shim::array_merge_map; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::package::BasePackageHandle; use crate::package::Link; use crate::package::PackageInterfaceHandle; @@ -18,6 +12,11 @@ use crate::repository::{ FindPackageConstraint, LoadPackagesResult, ProviderInfo, RepositoryInterface, RepositoryInterfaceHandle, SearchResult, }; +use indexmap::IndexMap; +use shirabe_php_shim::array_merge_map; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::SimpleConstraint; pub enum NeedleInput { Single(String), diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs index f573ee9..8249bb9 100644 --- a/crates/shirabe/src/repository/path_repository.rs +++ b/crates/shirabe/src/repository/path_repository.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Repository/PathRepository.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - DIRECTORY_SEPARATOR, GLOB_BRACE, GLOB_MARK, GLOB_ONLYDIR, PhpMixed, RuntimeException, defined, - file_exists, file_get_contents, glob_with_flags, hash, realpath, serialize, -}; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; @@ -29,6 +22,12 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + DIRECTORY_SEPARATOR, GLOB_BRACE, GLOB_MARK, GLOB_ONLYDIR, PhpMixed, RuntimeException, defined, + file_exists, file_get_contents, glob_with_flags, hash, realpath, serialize, +}; #[derive(Debug)] pub struct PathRepository { diff --git a/crates/shirabe/src/repository/platform_repository.rs b/crates/shirabe/src/repository/platform_repository.rs index ee1d26e..0fa5638 100644 --- a/crates/shirabe/src/repository/platform_repository.rs +++ b/crates/shirabe/src/repository/platform_repository.rs @@ -1,18 +1,5 @@ //! ref: composer/src/Composer/Repository/PlatformRepository.php -use std::sync::{LazyLock, Mutex}; - -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn, - array_slice_strs, explode, get_class, implode, in_array, is_string, str_replace, - str_starts_with, strpos, strtolower, var_export, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer; use crate::package::CompletePackage; use crate::package::CompletePackageHandle; @@ -31,6 +18,16 @@ use crate::plugin::plugin_interface::{self}; use crate::repository::ArrayRepository; use crate::repository::RepositoryInterface; use crate::util::Silencer; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_external_packages::composer::xdebug_handler::XdebugHandler; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, array_map_str_fn, + array_slice_strs, explode, get_class, implode, in_array, is_string, str_replace, + str_starts_with, strpos, strtolower, var_export, +}; +use shirabe_semver::constraint::SimpleConstraint; +use std::sync::{LazyLock, Mutex}; static LAST_SEEN_PLATFORM_PHP: LazyLock<Mutex<Option<String>>> = LazyLock::new(|| Mutex::new(None)); @@ -1810,8 +1807,6 @@ impl PlatformRepository { self.inner.search(query, mode, r#type) } - // ---- helpers ---- - fn is_complete_package(package: PackageInterfaceHandle) -> bool { package.as_complete().is_some() } diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs index bc08589..23766bf 100644 --- a/crates/shirabe/src/repository/repository_factory.rs +++ b/crates/shirabe/src/repository/repository_factory.rs @@ -1,12 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositoryFactory.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, UnexpectedValueException, get_debug_type, json_encode, - php_to_string, -}; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::factory::Factory; @@ -18,6 +11,12 @@ use crate::repository::RepositoryManager; use crate::repository::RepositoryManagerInterface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, UnexpectedValueException, get_debug_type, json_encode, + php_to_string, +}; pub struct RepositoryFactory; diff --git a/crates/shirabe/src/repository/repository_manager.rs b/crates/shirabe/src/repository/repository_manager.rs index 41f4e7d..eb755dc 100644 --- a/crates/shirabe/src/repository/repository_manager.rs +++ b/crates/shirabe/src/repository/repository_manager.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositoryManager.php -use indexmap::IndexMap; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, json_encode}; -use shirabe_semver::constraint::AnyConstraint; - use crate::config::Config; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; @@ -13,6 +9,9 @@ use crate::repository::FilterRepository; use crate::repository::RepositoryInterfaceHandle; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, json_encode}; +use shirabe_semver::constraint::AnyConstraint; #[derive(Debug)] pub struct RepositoryManager { diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs index f8514cb..c19f61a 100644 --- a/crates/shirabe/src/repository/repository_set.rs +++ b/crates/shirabe/src/repository/repository_set.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Repository/RepositorySet.php -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_php_shim::{LogicException, RuntimeException, ksort, strtolower}; -use shirabe_semver::constraint::AnyConstraint; -use shirabe_semver::constraint::MatchAllConstraint; -use shirabe_semver::constraint::MultiConstraint; -use shirabe_semver::constraint::SimpleConstraint; - use crate::advisory::AnySecurityAdvisory; use crate::dependency_resolver::Pool; use crate::dependency_resolver::PoolBuilder; @@ -28,6 +20,13 @@ use crate::repository::InstalledRepository; use crate::repository::LockArrayRepositoryHandle; use crate::repository::PlatformRepository; use crate::repository::{FindPackageConstraint, RepositoryInterfaceHandle}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_php_shim::{LogicException, RuntimeException, ksort, strtolower}; +use shirabe_semver::constraint::AnyConstraint; +use shirabe_semver::constraint::MatchAllConstraint; +use shirabe_semver::constraint::MultiConstraint; +use shirabe_semver::constraint::SimpleConstraint; #[derive(Debug, Clone)] pub struct RootAliasEntry { diff --git a/crates/shirabe/src/repository/vcs/mod.rs b/crates/shirabe/src/repository/vcs.rs index 5c60e0a..5c60e0a 100644 --- a/crates/shirabe/src/repository/vcs/mod.rs +++ b/crates/shirabe/src/repository/vcs.rs diff --git a/crates/shirabe/src/repository/vcs/forgejo_driver.rs b/crates/shirabe/src/repository/vcs/forgejo_driver.rs index 4d66f37..9557847 100644 --- a/crates/shirabe/src/repository/vcs/forgejo_driver.rs +++ b/crates/shirabe/src/repository/vcs/forgejo_driver.rs @@ -1,18 +1,11 @@ //! ref: composer/src/Composer/Repository/Vcs/ForgejoDriver.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -21,6 +14,12 @@ use crate::util::Forgejo; use crate::util::ForgejoRepositoryData; use crate::util::ForgejoUrl; use crate::util::http::Response; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, base64_decode, explode, extension_loaded, urlencode, +}; #[derive(Debug)] pub struct ForgejoDriver { diff --git a/crates/shirabe/src/repository/vcs/fossil_driver.rs b/crates/shirabe/src/repository/vcs/fossil_driver.rs index be3beff..840a2ae 100644 --- a/crates/shirabe/src/repository/vcs/fossil_driver.rs +++ b/crates/shirabe/src/repository/vcs/fossil_driver.rs @@ -1,19 +1,18 @@ //! ref: composer/src/Composer/Repository/Vcs/FossilDriver.php -use crate::io::io_interface; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::repository::vcs::VcsDriverBase; use crate::util::Filesystem; use crate::util::ProcessExecutor; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{PhpMixed, RuntimeException, dirname, is_dir, is_file, is_writable}; #[derive(Debug)] pub struct FossilDriver { diff --git a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs index 7a570bc..f28a005 100644 --- a/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_bitbucket_driver.rs @@ -1,21 +1,11 @@ //! ref: composer/src/Composer/Repository/Vcs/GitBitbucketDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists, - array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array, - strpos, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase; use crate::repository::vcs::VcsDriverInterface; use crate::util::Bitbucket; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_key_exists, + array_search_mixed, extension_loaded, http_build_query_mixed, implode, in_array, is_array, + strpos, +}; #[derive(Debug)] pub struct GitBitbucketDriver { diff --git a/crates/shirabe/src/repository/vcs/git_driver.rs b/crates/shirabe/src/repository/vcs/git_driver.rs index cd08117..1455383 100644 --- a/crates/shirabe/src/repository/vcs/git_driver.rs +++ b/crates/shirabe/src/repository/vcs/git_driver.rs @@ -1,26 +1,25 @@ //! ref: composer/src/Composer/Repository/Vcs/GitDriver.php -use crate::io::io_interface; -use chrono::TimeZone; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath, - sys_get_temp_dir, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::repository::vcs::VcsDriverBase; use crate::util::Filesystem; use crate::util::Git as GitUtil; use crate::util::ProcessExecutor; use crate::util::Url; +use chrono::TimeZone; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_php_shim::PhpMixed; +use shirabe_php_shim::{ + InvalidArgumentException, RuntimeException, dirname, is_dir, is_writable, realpath, + sys_get_temp_dir, +}; #[derive(Debug)] pub struct GitDriver { diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs index e45096d..e8e67ea 100644 --- a/crates/shirabe/src/repository/vcs/github_driver.rs +++ b/crates/shirabe/src/repository/vcs/github_driver.rs @@ -1,27 +1,26 @@ //! ref: composer/src/Composer/Repository/Vcs/GitHubDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map, - array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array, - parse_url_all, strpos, strtolower, substr, trim, urlencode, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; use crate::repository::vcs::VcsDriverBase; use crate::util::GitHub; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, PhpMixed, RuntimeException, array_diff, array_key_exists, array_map, + array_search_mixed, base64_decode, basename, empty, explode, extension_loaded, in_array, + parse_url_all, strpos, strtolower, substr, trim, urlencode, +}; #[derive(Debug)] pub struct GitHubDriver { diff --git a/crates/shirabe/src/repository/vcs/gitlab_driver.rs b/crates/shirabe/src/repository/vcs/gitlab_driver.rs index a9a2fdb..136d0d6 100644 --- a/crates/shirabe/src/repository/vcs/gitlab_driver.rs +++ b/crates/shirabe/src/repository/vcs/gitlab_driver.rs @@ -1,21 +1,11 @@ //! ref: composer/src/Composer/Repository/Vcs/GitLabDriver.php -use crate::io::io_interface; -use anyhow::Result; -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, - array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array, - is_string, ord, strpos, strtolower, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::json::JsonEncodeOptions; use crate::json::JsonFile; use crate::repository::vcs::GitDriver; @@ -23,6 +13,15 @@ use crate::repository::vcs::VcsDriverBase; use crate::util::GitLab; use crate::util::HttpDownloader; use crate::util::http::Response; +use anyhow::Result; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, RuntimeException, array_search_mixed, + array_shift, ctype_alnum, empty, explode, extension_loaded, implode, in_array, is_array, + is_string, ord, strpos, strtolower, +}; /// Driver for GitLab API, use the Git driver for local checkouts. #[derive(Debug)] diff --git a/crates/shirabe/src/repository/vcs/perforce_driver.rs b/crates/shirabe/src/repository/vcs/perforce_driver.rs index cb280e5..55a8eae 100644 --- a/crates/shirabe/src/repository/vcs/perforce_driver.rs +++ b/crates/shirabe/src/repository/vcs/perforce_driver.rs @@ -1,9 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/PerforceDriver.php -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException}; - use crate::cache::Cache; use crate::config::Config; use crate::io::IOInterface; @@ -12,6 +8,9 @@ use crate::util::Perforce; use crate::util::PerforceInterface; use crate::util::ProcessExecutor; use crate::util::http::Response; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{BadMethodCallException, PhpMixed, RuntimeException}; #[derive(Debug)] pub struct PerforceDriver { diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index 087ed9d..cb4ff87 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -1,13 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/SvnDriver.php -use anyhow::Result; -use chrono::{DateTime, FixedOffset, Utc}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim, -}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; @@ -19,6 +11,13 @@ use crate::util::Filesystem; use crate::util::ProcessExecutor; use crate::util::Svn as SvnUtil; use crate::util::Url; +use anyhow::Result; +use chrono::{DateTime, FixedOffset, Utc}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PhpMixed, RuntimeException, array_key_exists, stripos, strrpos, strtr, substr, trim, +}; #[derive(Debug)] pub struct SvnDriver { diff --git a/crates/shirabe/src/repository/vcs/vcs_driver.rs b/crates/shirabe/src/repository/vcs/vcs_driver.rs index 5e0715c..1dce856 100644 --- a/crates/shirabe/src/repository/vcs/vcs_driver.rs +++ b/crates/shirabe/src/repository/vcs/vcs_driver.rs @@ -1,10 +1,5 @@ //! ref: composer/src/Composer/Repository/Vcs/VcsDriver.php -use chrono::{DateTime, FixedOffset}; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded}; - use crate::cache::Cache; use crate::config::Config; use crate::downloader::TransportException; @@ -15,6 +10,10 @@ use crate::repository::vcs::VcsDriverInterface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; use crate::util::http::Response; +use chrono::{DateTime, FixedOffset}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{DATE_RFC3339, PhpMixed, extension_loaded}; #[derive(Debug)] pub struct VcsDriverBase { diff --git a/crates/shirabe/src/repository/vcs_repository.rs b/crates/shirabe/src/repository/vcs_repository.rs index 901276a..d799532 100644 --- a/crates/shirabe/src/repository/vcs_repository.rs +++ b/crates/shirabe/src/repository/vcs_repository.rs @@ -1,17 +1,11 @@ //! ref: composer/src/Composer/Repository/VcsRepository.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{InvalidArgumentException, PhpMixed, in_array, str_replace, strpos}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::config::Config; use crate::downloader::TransportException; use crate::event_dispatcher::EventDispatcher; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::package::BasePackageHandle; use crate::package::PackageInterfaceHandle; use crate::package::loader::ArrayLoader; @@ -32,6 +26,11 @@ use crate::util::HttpDownloader; use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{InvalidArgumentException, PhpMixed, in_array, str_replace, strpos}; +use shirabe_semver::constraint::SimpleConstraint; // TODO(phase-c): the driver registration should be refactored later. #[derive(Debug)] diff --git a/crates/shirabe/src/script/mod.rs b/crates/shirabe/src/script.rs index e8b657f..e8b657f 100644 --- a/crates/shirabe/src/script/mod.rs +++ b/crates/shirabe/src/script.rs diff --git a/crates/shirabe/src/self_update/mod.rs b/crates/shirabe/src/self_update.rs index 5594811..5594811 100644 --- a/crates/shirabe/src/self_update/mod.rs +++ b/crates/shirabe/src/self_update.rs diff --git a/crates/shirabe/src/util/mod.rs b/crates/shirabe/src/util.rs index bd51b66..bd51b66 100644 --- a/crates/shirabe/src/util/mod.rs +++ b/crates/shirabe/src/util.rs diff --git a/crates/shirabe/src/util/auth_helper.rs b/crates/shirabe/src/util/auth_helper.rs index 584ce69..8a89842 100644 --- a/crates/shirabe/src/util/auth_helper.rs +++ b/crates/shirabe/src/util/auth_helper.rs @@ -1,6 +1,13 @@ //! ref: composer/src/Composer/Util/AuthHelper.php +use crate::config::Config; +use crate::downloader::TransportException; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::util::Bitbucket; +use crate::util::GitHub; +use crate::util::GitLab; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -10,14 +17,6 @@ use shirabe_php_shim::{ trim, }; -use crate::config::Config; -use crate::downloader::TransportException; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Bitbucket; -use crate::util::GitHub; -use crate::util::GitLab; - #[derive(Debug)] pub struct AuthHelper { pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, diff --git a/crates/shirabe/src/util/bitbucket.rs b/crates/shirabe/src/util/bitbucket.rs index 8a1127a..bba16e8 100644 --- a/crates/shirabe/src/util/bitbucket.rs +++ b/crates/shirabe/src/util/bitbucket.rs @@ -1,16 +1,15 @@ //! ref: composer/src/Composer/Util/Bitbucket.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_php_shim::{LogicException, PhpMixed, time}; - use crate::config::Config; use crate::downloader::TransportException; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_php_shim::{LogicException, PhpMixed, time}; fn transport_error_code(err: &anyhow::Error) -> Option<i64> { err.downcast_ref::<TransportException>().map(|te| te.code) diff --git a/crates/shirabe/src/util/filesystem.rs b/crates/shirabe/src/util/filesystem.rs index b224767..d21a0e7 100644 --- a/crates/shirabe/src/util/filesystem.rs +++ b/crates/shirabe/src/util/filesystem.rs @@ -1,5 +1,8 @@ //! ref: composer/src/Composer/Util/Filesystem.php +use crate::util::Platform; +use crate::util::ProcessExecutor; +use crate::util::Silencer; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::filesystem::exception::IOException; use shirabe_external_packages::symfony::finder::Finder; @@ -12,13 +15,8 @@ use shirabe_php_shim::{ str_starts_with, strlen, strpos, strtoupper, strtr, substr, substr_count, symlink, touch, unlink, usleep, var_export, }; - use std::path::Path; -use crate::util::Platform; -use crate::util::ProcessExecutor; -use crate::util::Silencer; - #[derive(Debug)] pub struct Filesystem { process_executor: Option<std::rc::Rc<std::cell::RefCell<ProcessExecutor>>>, diff --git a/crates/shirabe/src/util/git.rs b/crates/shirabe/src/util/git.rs index f30f9f7..ee9f9e6 100644 --- a/crates/shirabe/src/util/git.rs +++ b/crates/shirabe/src/util/git.rs @@ -1,20 +1,9 @@ //! ref: composer/src/Composer/Util/Git.php -use crate::io::io_interface; -use anyhow::Result; -use indexmap::IndexMap; -use std::sync::Mutex; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache, - explode, implode, in_array, is_callable, is_dir, preg_quote, rawurldecode, rawurlencode, - str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim, version_compare, -}; - use crate::config::Config; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::Bitbucket; use crate::util::Filesystem; use crate::util::GitHub; @@ -24,6 +13,15 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use crate::util::Url; use crate::util::{AuthHelper, StoreAuth}; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, PHP_EOL, PhpMixed, RuntimeException, array_map, clearstatcache, + explode, implode, in_array, is_callable, is_dir, preg_quote, rawurldecode, rawurlencode, + str_contains, str_ends_with, str_replace_array, strlen, strpos, substr, trim, version_compare, +}; +use std::sync::Mutex; #[derive(Debug)] pub struct Git { diff --git a/crates/shirabe/src/util/github.rs b/crates/shirabe/src/util/github.rs index 285052e..905026a 100644 --- a/crates/shirabe/src/util/github.rs +++ b/crates/shirabe/src/util/github.rs @@ -1,16 +1,15 @@ //! ref: composer/src/Composer/Util/GitHub.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{PhpMixed, date, stripos, strtolower}; - use crate::config::Config; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{PhpMixed, date, stripos, strtolower}; #[derive(Debug)] pub struct GitHub { diff --git a/crates/shirabe/src/util/gitlab.rs b/crates/shirabe/src/util/gitlab.rs index a71c231..eae26f0 100644 --- a/crates/shirabe/src/util/gitlab.rs +++ b/crates/shirabe/src/util/gitlab.rs @@ -1,17 +1,16 @@ //! ref: composer/src/Composer/Util/GitLab.php -use crate::io::io_interface; -use indexmap::IndexMap; -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{PhpMixed, RuntimeException, http_build_query, json_decode, time}; - use crate::config::Config; use crate::downloader::TransportException; use crate::factory::Factory; use crate::io::IOInterface; use crate::io::IOInterfaceImmutable; +use crate::io::io_interface; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{PhpMixed, RuntimeException, http_build_query, json_decode, time}; #[derive(Debug)] pub struct GitLab { diff --git a/crates/shirabe/src/util/http/mod.rs b/crates/shirabe/src/util/http.rs index 19e5a86..19e5a86 100644 --- a/crates/shirabe/src/util/http/mod.rs +++ b/crates/shirabe/src/util/http.rs diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs index 66ca326..019a5ab 100644 --- a/crates/shirabe/src/util/http/curl_downloader.rs +++ b/crates/shirabe/src/util/http/curl_downloader.rs @@ -10,15 +10,6 @@ //! is preserved. Per-request TLS/proxy/IP-resolve settings that reqwest only exposes per-Client //! are simplified to a single default Client; see the TODOs below. -use std::sync::atomic::{AtomicBool, Ordering}; - -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::Preg; -use shirabe_php_shim::{ - PhpMixed, in_array, parse_url, preg_quote, rename, strpos, substr, unlink_silent, -}; - use crate::config::Config; use crate::downloader::MaxFileSizeExceededException; use crate::downloader::TransportException; @@ -31,6 +22,12 @@ use crate::util::http::CurlResponse; use crate::util::http::ProxyManager; use crate::util::http::Response; use crate::util::{AuthHelper, PromptAuthResult, StoreAuth}; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::Preg; +use shirabe_php_shim::{ + PhpMixed, in_array, parse_url, preg_quote, rename, strpos, substr, unlink_silent, +}; +use std::sync::atomic::{AtomicBool, Ordering}; /// resolve callback supplied by `HttpDownloader`. Receives the final `Response` on success. pub type ResolveCallback = Box<dyn Fn(Response) + Send + Sync>; diff --git a/crates/shirabe/src/util/http/curl_response.rs b/crates/shirabe/src/util/http/curl_response.rs index cc3d21b..579bba8 100644 --- a/crates/shirabe/src/util/http/curl_response.rs +++ b/crates/shirabe/src/util/http/curl_response.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Util/Http/CurlResponse.php +use super::Response; use indexmap::IndexMap; use shirabe_php_shim::PhpMixed; -use super::Response; - #[derive(Debug)] pub struct CurlResponse { pub(crate) inner: Response, diff --git a/crates/shirabe/src/util/http/proxy_manager.rs b/crates/shirabe/src/util/http/proxy_manager.rs index d0ff9d9..3bc0888 100644 --- a/crates/shirabe/src/util/http/proxy_manager.rs +++ b/crates/shirabe/src/util/http/proxy_manager.rs @@ -1,12 +1,11 @@ //! ref: composer/src/Composer/Util/Http/ProxyManager.php -use std::sync::atomic::{AtomicU64, Ordering}; -use std::sync::{Mutex, OnceLock}; - use crate::downloader::TransportException; use crate::util::NoProxyPattern; use crate::util::http::ProxyItem; use crate::util::http::RequestProxy; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Mutex, OnceLock}; static INSTANCE: OnceLock<Mutex<Option<ProxyManager>>> = OnceLock::new(); diff --git a/crates/shirabe/src/util/http/request_proxy.rs b/crates/shirabe/src/util/http/request_proxy.rs index 49aa885..1262622 100644 --- a/crates/shirabe/src/util/http/request_proxy.rs +++ b/crates/shirabe/src/util/http/request_proxy.rs @@ -1,13 +1,12 @@ //! ref: composer/src/Composer/Util/Http/RequestProxy.php +use crate::downloader::TransportException; use indexmap::IndexMap; use shirabe_php_shim::{ CURLAUTH_BASIC, CURLOPT_NOPROXY, CURLOPT_PROXY, CURLOPT_PROXY_CAINFO, CURLOPT_PROXY_CAPATH, CURLOPT_PROXYAUTH, CURLOPT_PROXYUSERPWD, InvalidArgumentException, PhpMixed, }; -use crate::downloader::TransportException; - // contextOptions = array{http: array{proxy: string, header?: string, request_fulluri?: bool}} type ContextOptions = IndexMap<String, IndexMap<String, PhpMixed>>; diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs index a6b62d7..18e320c 100644 --- a/crates/shirabe/src/util/http_downloader.rs +++ b/crates/shirabe/src/util/http_downloader.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Util/HttpDownloader.php -use anyhow::Result; -use indexmap::IndexMap; - -use crate::util::Silencer; -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr, - extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode, - stream_context_create, stripos, strpos, substr, ucfirst, -}; -use shirabe_semver::constraint::SimpleConstraint; - use crate::composer; use crate::config::Config; use crate::downloader::TransportException; @@ -21,10 +9,20 @@ use crate::package::version::VersionParser; use crate::util::GetResult; use crate::util::Platform; use crate::util::RemoteFilesystem; +use crate::util::Silencer; use crate::util::StreamContextFactory; use crate::util::Url; use crate::util::http::CurlDownloader; use crate::util::http::Response; +use anyhow::Result; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + InvalidArgumentException, LogicException, PhpMixed, array_replace_recursive, chr, + extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode, + stream_context_create, stripos, strpos, substr, ucfirst, +}; +use shirabe_semver::constraint::SimpleConstraint; /// @phpstan-type Request array{url: non-empty-string, options: mixed[], copyTo: string|null} /// @phpstan-type Job array{id: int, status: int, request: Request, sync: bool, origin: string, resolve?: callable, reject?: callable, curl_id?: int, response?: Response, exception?: \Throwable} diff --git a/crates/shirabe/src/util/package_sorter.rs b/crates/shirabe/src/util/package_sorter.rs index 6e0af01..4b76c2f 100644 --- a/crates/shirabe/src/util/package_sorter.rs +++ b/crates/shirabe/src/util/package_sorter.rs @@ -1,10 +1,9 @@ //! ref: composer/src/Composer/Util/PackageSorter.php -use indexmap::IndexMap; -use shirabe_php_shim::{strnatcasecmp, version_compare}; - use crate::package::Link; use crate::package::PackageInterfaceHandle; +use indexmap::IndexMap; +use shirabe_php_shim::{strnatcasecmp, version_compare}; pub struct PackageSorter; diff --git a/crates/shirabe/src/util/perforce.rs b/crates/shirabe/src/util/perforce.rs index d8cd39d..bd8e9e6 100644 --- a/crates/shirabe/src/util/perforce.rs +++ b/crates/shirabe/src/util/perforce.rs @@ -1,5 +1,10 @@ //! ref: composer/src/Composer/Util/Perforce.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::ProcessExecutor; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::Preg; @@ -11,12 +16,6 @@ use shirabe_php_shim::{ strpos, strrpos, substr, time, trim, }; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::ProcessExecutor; - /// @phpstan-type RepoConfig array{unique_perforce_client_name?: string, depot?: string, branch?: string, p4user?: string, p4password?: string} #[derive(Debug)] pub struct Perforce { diff --git a/crates/shirabe/src/util/platform.rs b/crates/shirabe/src/util/platform.rs index 889da6e..b3b7e2b 100644 --- a/crates/shirabe/src/util/platform.rs +++ b/crates/shirabe/src/util/platform.rs @@ -1,7 +1,7 @@ //! ref: composer/src/Composer/Util/Platform.php -use std::sync::Mutex; - +use crate::util::ProcessExecutor; +use crate::util::Silencer; use anyhow::Result; use shirabe_external_packages::composer::pcre::Preg; use shirabe_php_shim::{ @@ -11,9 +11,7 @@ use shirabe_php_shim::{ posix_isatty, putenv, putenv_clear, realpath, stream_isatty, stripos, strlen, strtoupper, substr, usleep, }; - -use crate::util::ProcessExecutor; -use crate::util::Silencer; +use std::sync::Mutex; /// Platform helper for uniform platform-specific tests. pub struct Platform; diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs index 98c3186..230695a 100644 --- a/crates/shirabe/src/util/process_executor.rs +++ b/crates/shirabe/src/util/process_executor.rs @@ -1,10 +1,12 @@ //! ref: composer/src/Composer/Util/ProcessExecutor.php +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; +use crate::util::GitHub; +use crate::util::Platform; use anyhow::Result; use indexmap::IndexMap; -use std::sync::{LazyLock, Mutex}; - use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; use shirabe_external_packages::seld::signal::SignalHandler; use shirabe_external_packages::symfony::process::ExecutableFinder; @@ -16,11 +18,7 @@ use shirabe_php_shim::{ explode, implode, in_array, is_array, is_dir, is_numeric, is_string, rtrim, sprintf, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array, substr_replace, trim, usleep, }; - -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::GitHub; -use crate::util::Platform; +use std::sync::{LazyLock, Mutex}; static EXECUTABLES: LazyLock<Mutex<IndexMap<String, String>>> = LazyLock::new(|| Mutex::new(IndexMap::new())); diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs index ca818fc..aa42f6b 100644 --- a/crates/shirabe/src/util/remote_filesystem.rs +++ b/crates/shirabe/src/util/remote_filesystem.rs @@ -1,17 +1,5 @@ //! ref: composer/src/Composer/Util/RemoteFilesystem.php -use indexmap::IndexMap; - -use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; -use shirabe_php_shim::{ - PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PHP_VERSION_ID, PhpMixed, RuntimeException, - STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, - array_replace_recursive, base64_encode, explode, extension_loaded, file_put_contents, - filter_var_boolean, gethostbyname, http_clear_last_response_headers, - http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, strpos, - strtolower, strtr, substr, trim, zlib_decode, -}; - use crate::config::Config; use crate::downloader::MaxFileSizeExceededException; use crate::downloader::TransportException; @@ -24,6 +12,16 @@ use crate::util::StreamContextFactory; use crate::util::Url; use crate::util::http::ProxyManager; use crate::util::http::Response; +use indexmap::IndexMap; +use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; +use shirabe_php_shim::{ + PHP_URL_HOST, PHP_URL_PATH, PHP_URL_SCHEME, PHP_VERSION_ID, PhpMixed, RuntimeException, + STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, + array_replace_recursive, base64_encode, explode, extension_loaded, file_put_contents, + filter_var_boolean, gethostbyname, http_clear_last_response_headers, + http_get_last_response_headers, ini_get, json_decode, parse_url, preg_quote, strpos, + strtolower, strtr, substr, trim, zlib_decode, +}; /// Result of `RemoteFilesystem::get` — string content, `true` (for copy), or `false`. #[derive(Debug, Clone)] diff --git a/crates/shirabe/src/util/stream_context_factory.rs b/crates/shirabe/src/util/stream_context_factory.rs index 0b259d7..6a40cd0 100644 --- a/crates/shirabe/src/util/stream_context_factory.rs +++ b/crates/shirabe/src/util/stream_context_factory.rs @@ -1,5 +1,11 @@ //! ref: composer/src/Composer/Util/StreamContextFactory.php +use crate::composer; +use crate::downloader::TransportException; +use crate::repository::PlatformRepository; +use crate::util::Filesystem; +use crate::util::Platform; +use crate::util::http::ProxyManager; use indexmap::IndexMap; use shirabe_external_packages::composer::ca_bundle::CaBundle; use shirabe_php_shim::{ @@ -8,13 +14,6 @@ use shirabe_php_shim::{ stripos, uasort, }; -use crate::composer; -use crate::downloader::TransportException; -use crate::repository::PlatformRepository; -use crate::util::Filesystem; -use crate::util::Platform; -use crate::util::http::ProxyManager; - pub struct StreamContextFactory; impl StreamContextFactory { diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs index 096d8c3..5eed44d 100644 --- a/crates/shirabe/src/util/svn.rs +++ b/crates/shirabe/src/util/svn.rs @@ -1,8 +1,11 @@ //! ref: composer/src/Composer/Util/Svn.php +use crate::config::Config; +use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::io::io_interface; -use std::sync::Mutex; - +use crate::util::Platform; +use crate::util::ProcessExecutor; use anyhow::Result; use indexmap::IndexMap; use shirabe_external_packages::composer::pcre::{CaptureKey, Preg}; @@ -10,12 +13,7 @@ use shirabe_php_shim::{ LogicException, PHP_URL_HOST, PhpMixed, RuntimeException, empty, implode, parse_url, parse_url_all, stripos, strpos, trim, }; - -use crate::config::Config; -use crate::io::IOInterface; -use crate::io::IOInterfaceImmutable; -use crate::util::Platform; -use crate::util::ProcessExecutor; +use std::sync::Mutex; #[derive(Debug, Clone)] pub struct SvnCredentials { diff --git a/crates/shirabe/tests/advisory/auditor_test.rs b/crates/shirabe/tests/advisory/auditor_test.rs index 516c4d1..c908f0b 100644 --- a/crates/shirabe/tests/advisory/auditor_test.rs +++ b/crates/shirabe/tests/advisory/auditor_test.rs @@ -1,5 +1,8 @@ //! ref: composer/tests/Composer/Test/Advisory/AuditorTest.php +use crate::io_mock::{Expectation, get_io_mock}; +use crate::test_case::get_complete_package; +use crate::test_case::get_package; use chrono::Utc; use indexmap::IndexMap; use shirabe::advisory::AnySecurityAdvisory; @@ -26,10 +29,6 @@ use shirabe_semver::VersionParser; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::SimpleConstraint; -use crate::io_mock::{Expectation, get_io_mock}; -use crate::test_case::get_complete_package; -use crate::test_case::get_package; - fn constraint(operator: &str, version: &str) -> shirabe_semver::constraint::AnyConstraint { SimpleConstraint::new(operator.to_string(), version.to_string(), None).into() } diff --git a/crates/shirabe/tests/application_test.rs b/crates/shirabe/tests/application_test.rs index d54f43b..a513189 100644 --- a/crates/shirabe/tests/application_test.rs +++ b/crates/shirabe/tests/application_test.rs @@ -5,9 +5,6 @@ // Symfony command-registry model), or a runtime define() of COMPOSER_DEV_WARNING_TIME, // remain unportable. -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::command::about_command::AboutCommand; use shirabe::command::self_update_command::SelfUpdateCommand; use shirabe::console::application::ApplicationHandle; @@ -18,6 +15,8 @@ use shirabe_external_packages::symfony::console::input::input_interface::InputIn use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; fn set_up() { Platform::put_env("COMPOSER_DISABLE_XDEBUG_WARN", "1"); diff --git a/crates/shirabe/tests/autoload/autoload_generator_test.rs b/crates/shirabe/tests/autoload/autoload_generator_test.rs index d5f16fb..73182a2 100644 --- a/crates/shirabe/tests/autoload/autoload_generator_test.rs +++ b/crates/shirabe/tests/autoload/autoload_generator_test.rs @@ -1,12 +1,8 @@ //! ref: composer/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; use indexmap::IndexMap; use serial_test::serial; -use tempfile::TempDir; - use shirabe::autoload::AutoloadGenerator; use shirabe::composer::{ComposerHandle, PartialOrFullComposer}; use shirabe::config::Config; @@ -23,8 +19,9 @@ use shirabe::util::r#loop::Loop; use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint, SimpleConstraint}; - -use crate::config_stub::ConfigStubBuilder; +use std::cell::RefCell; +use std::rc::Rc; +use tempfile::TempDir; /// The mock `InstallationManager::getInstallPath` used throughout the test: metapackages return /// null, every other package returns `vendorDir/<name>(/<targetDir>)`. Registered as an installer diff --git a/crates/shirabe/tests/cache_test.rs b/crates/shirabe/tests/cache_test.rs index 7705714..b9644dc 100644 --- a/crates/shirabe/tests/cache_test.rs +++ b/crates/shirabe/tests/cache_test.rs @@ -1,13 +1,12 @@ //! ref: composer/tests/Composer/Test/CacheTest.php -use std::cell::RefCell; -use std::fs; -use std::rc::Rc; - use shirabe::cache::{Cache, CacheMock, GcFinderMock}; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::filesystem::Filesystem; +use std::cell::RefCell; +use std::fs; +use std::rc::Rc; use tempfile::TempDir; struct SetUp { diff --git a/crates/shirabe/tests/command/archive_command_test.rs b/crates/shirabe/tests/command/archive_command_test.rs index e7730b9..991f615 100644 --- a/crates/shirabe/tests/command/archive_command_test.rs +++ b/crates/shirabe/tests/command/archive_command_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Command/ArchiveCommandTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; use indexmap::IndexMap; use shirabe::command::BaseCommand; use shirabe::command::archive_command::ArchiveCommand; @@ -24,8 +22,8 @@ use shirabe_external_packages::symfony::console::output::OutputInterface; use shirabe_external_packages::symfony::console::output::buffered_output::BufferedOutput; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; - -use crate::config_stub::ConfigStubBuilder; +use std::cell::RefCell; +use std::rc::Rc; // PHP mocks `Composer\Package\Archiver\ArchiveManager` with // getMockBuilder(...)->disableOriginalConstructor(). diff --git a/crates/shirabe/tests/command/exec_command_test.rs b/crates/shirabe/tests/command/exec_command_test.rs index 95649f7..03a2c7c 100644 --- a/crates/shirabe/tests/command/exec_command_test.rs +++ b/crates/shirabe/tests/command/exec_command_test.rs @@ -71,7 +71,7 @@ fn test_list() { let output = app_tester.get_display(); - assert_eq!("Available binaries:\n- b\n- c\n- a (local)", output.trim(),); + assert_eq!("Available binaries:\n- b\n- c\n- a (local)", output.trim()); drop(tear_down); } diff --git a/crates/shirabe/tests/command/run_script_command_test.rs b/crates/shirabe/tests/command/run_script_command_test.rs index 6cd4a2e..75cf678 100644 --- a/crates/shirabe/tests/command/run_script_command_test.rs +++ b/crates/shirabe/tests/command/run_script_command_test.rs @@ -1,9 +1,8 @@ //! ref: composer/tests/Composer/Test/Command/RunScriptCommandTest.php -use shirabe_php_shim::PhpMixed; - use crate::test_case::{RunOptions, get_application_tester, init_temp_composer}; use serial_test::serial; +use shirabe_php_shim::PhpMixed; /// ref: RunScriptCommandTest::testDetectAndPassDevModeToEventAndToDispatching /// diff --git a/crates/shirabe/tests/common/config_stub.rs b/crates/shirabe/tests/common/config_stub.rs index 7566b89..bf81462 100644 --- a/crates/shirabe/tests/common/config_stub.rs +++ b/crates/shirabe/tests/common/config_stub.rs @@ -8,12 +8,11 @@ //! real resolution logic instead of intercepting `get`. #![allow(dead_code)] -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; pub struct ConfigStubBuilder { use_environment: bool, diff --git a/crates/shirabe/tests/common/http_downloader_mock.rs b/crates/shirabe/tests/common/http_downloader_mock.rs index 7a021f9..85d3ec8 100644 --- a/crates/shirabe/tests/common/http_downloader_mock.rs +++ b/crates/shirabe/tests/common/http_downloader_mock.rs @@ -1,9 +1,6 @@ //! ref: composer/tests/Composer/Test/Mock/HttpDownloaderMock.php #![allow(dead_code)] -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,6 +9,8 @@ use shirabe::util::http_downloader::{ HttpDownloader, HttpDownloaderMockExpectation, HttpDownloaderMockHandler, }; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; // A single HTTP request expectation as written in the PHP tests: a `url` plus an // optional response (`status`/`body`/`headers`). `options` of `None` matches any diff --git a/crates/shirabe/tests/common/io_mock.rs b/crates/shirabe/tests/common/io_mock.rs index bdbe7b3..7b932a8 100644 --- a/crates/shirabe/tests/common/io_mock.rs +++ b/crates/shirabe/tests/common/io_mock.rs @@ -1,9 +1,5 @@ //! ref: composer/tests/Composer/Test/Mock/IOMock.php -use std::cell::RefCell; -use std::collections::VecDeque; -use std::rc::Rc; - use shirabe::config::Config; use shirabe::io::buffer_io::BufferIO; use shirabe::io::io_interface; @@ -12,6 +8,9 @@ use shirabe::util::platform::Platform; use shirabe_external_packages::composer::pcre::Preg; use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::{PHP_EOL, PhpMixed, preg_quote}; +use std::cell::RefCell; +use std::collections::VecDeque; +use std::rc::Rc; // A single entry of the IO expectation list. PHP models these as associative // arrays (`{text, regex?}` / `{ask, reply}` / `{auth: [repo, user, pass]}`); the diff --git a/crates/shirabe/tests/common/process_executor_mock.rs b/crates/shirabe/tests/common/process_executor_mock.rs index b81c8bb..698d8d2 100644 --- a/crates/shirabe/tests/common/process_executor_mock.rs +++ b/crates/shirabe/tests/common/process_executor_mock.rs @@ -1,10 +1,9 @@ //! ref: composer/tests/Composer/Test/Mock/ProcessExecutorMock.php -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; // A command expectation as written in the PHP tests: either a bare command // (`'git command'` / `['git', '--version']`) or the full diff --git a/crates/shirabe/tests/composer_test.rs b/crates/shirabe/tests/composer_test.rs index bffe4ce..c394f1e 100644 --- a/crates/shirabe/tests/composer_test.rs +++ b/crates/shirabe/tests/composer_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/ComposerTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::composer::Composer; use shirabe::config::Config; @@ -19,6 +16,8 @@ use shirabe::repository::RepositoryManagerInterface; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe::util::process_executor::ProcessExecutor; +use std::cell::RefCell; +use std::rc::Rc; fn null_io() -> Rc<RefCell<dyn IOInterface>> { Rc::new(RefCell::new(NullIO::new())) diff --git a/crates/shirabe/tests/config_test.rs b/crates/shirabe/tests/config_test.rs index b7eb5a5..61a1575 100644 --- a/crates/shirabe/tests/config_test.rs +++ b/crates/shirabe/tests/config_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/ConfigTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use serial_test::serial; use shirabe::advisory::Auditor; @@ -11,6 +8,8 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::Platform; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[path = "common/io_mock.rs"] #[allow(dead_code)] // io_mock exposes more helpers than this binary uses diff --git a/crates/shirabe/tests/dependency_resolver/default_policy_test.rs b/crates/shirabe/tests/dependency_resolver/default_policy_test.rs index 5b7995b..3757715 100644 --- a/crates/shirabe/tests/dependency_resolver/default_policy_test.rs +++ b/crates/shirabe/tests/dependency_resolver/default_policy_test.rs @@ -1,5 +1,6 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/DefaultPolicyTest.php +use crate::test_case::get_package; use indexmap::IndexMap; use serial_test::serial; use shirabe::dependency_resolver::PolicyInterface; @@ -13,8 +14,6 @@ use shirabe::repository::repository_set::RepositorySet; use shirabe::util::platform::Platform; use shirabe_semver::constraint::{AnyConstraint, SimpleConstraint}; -use crate::test_case::get_package; - #[allow(dead_code)] struct Fixtures { repository_set: RepositorySet, diff --git a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs index 0a6b0ca..548cb0d 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_builder_test.rs @@ -1,9 +1,5 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/PoolBuilderTest.php -use std::cell::RefCell; -use std::path::PathBuf; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::dependency_resolver::default_policy::DefaultPolicy; @@ -26,6 +22,9 @@ use shirabe::repository::repository_set::{RepositorySet, RootAliasInput}; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::PREG_SPLIT_DELIM_CAPTURE; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::path::PathBuf; +use std::rc::Rc; /// Maps the PHP `$loadPackage` closure: pops the optional `id` from the data, loads the /// package and records it in `package_ids` keyed by that id (erroring on duplicates). diff --git a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs index b5f70a1..3c4952e 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_optimizer_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/PoolOptimizerTest.php -use std::path::PathBuf; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::dependency_resolver::default_policy::DefaultPolicy; use shirabe::dependency_resolver::pool::Pool; @@ -17,6 +14,8 @@ use shirabe::repository::lock_array_repository::LockArrayRepository; use shirabe_external_packages::composer::pcre::preg::Preg; use shirabe_php_shim::PREG_SPLIT_DELIM_CAPTURE; use shirabe_php_shim::PhpMixed; +use std::path::PathBuf; +use std::rc::Rc; fn load_package(package_data: &PhpMixed) -> BasePackageHandle { let loader = ArrayLoader::new(None, false); diff --git a/crates/shirabe/tests/dependency_resolver/pool_test.rs b/crates/shirabe/tests/dependency_resolver/pool_test.rs index b2bd0db..409420b 100644 --- a/crates/shirabe/tests/dependency_resolver/pool_test.rs +++ b/crates/shirabe/tests/dependency_resolver/pool_test.rs @@ -1,11 +1,10 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/PoolTest.php +use crate::test_case::{get_package, get_version_constraint}; use indexmap::IndexMap; use shirabe::dependency_resolver::pool::Pool; use shirabe::package::handle::PackageInterfaceHandle; -use crate::test_case::{get_package, get_version_constraint}; - // ref: PoolTest::createPool fn create_pool(packages: Vec<PackageInterfaceHandle>) -> Pool { Pool::new( diff --git a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs index 44013aa..9c9f85b 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_set_iterator_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/RuleSetIteratorTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::dependency_resolver::generic_rule::GenericRule; use shirabe::dependency_resolver::pool::Pool; @@ -10,6 +7,8 @@ use shirabe::dependency_resolver::rule::{RULE_LEARNED, RULE_ROOT_REQUIRE, Reason use shirabe::dependency_resolver::rule_set::RuleSet; use shirabe::dependency_resolver::rule_set_iterator::RuleSetIterator; use shirabe_semver::constraint::MatchAllConstraint; +use std::cell::RefCell; +use std::rc::Rc; type Rules = IndexMap<i64, Vec<Rc<RefCell<Rule>>>>; diff --git a/crates/shirabe/tests/dependency_resolver/rule_set_test.rs b/crates/shirabe/tests/dependency_resolver/rule_set_test.rs index c1faa11..3ed974e 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_set_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_set_test.rs @@ -1,16 +1,14 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/RuleSetTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::dependency_resolver::{ GenericRule, Pool, RULE_LEARNED, RULE_ROOT_REQUIRE, ReasonData, Request, Rule, RuleSet, }; use shirabe::repository::RepositorySet; use shirabe_semver::constraint::{MatchAllConstraint, MatchNoneConstraint}; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; fn root_require_reason() -> ReasonData { ReasonData::RootRequire { diff --git a/crates/shirabe/tests/dependency_resolver/rule_test.rs b/crates/shirabe/tests/dependency_resolver/rule_test.rs index 8216848..6bfb7bd 100644 --- a/crates/shirabe/tests/dependency_resolver/rule_test.rs +++ b/crates/shirabe/tests/dependency_resolver/rule_test.rs @@ -1,5 +1,6 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/RuleTest.php +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::dependency_resolver::{ GenericRule, Pool, RULE_PACKAGE_REQUIRES, RULE_ROOT_REQUIRE, ReasonData, Request, Rule, RuleSet, @@ -9,8 +10,6 @@ use shirabe::repository::RepositorySet; use shirabe_php_shim::{PHP_VERSION_ID, hash_raw, unpack}; use shirabe_semver::constraint::MatchAllConstraint; -use crate::test_case::get_package; - fn root_require_reason() -> ReasonData { ReasonData::RootRequire { package_name: String::new(), diff --git a/crates/shirabe/tests/dependency_resolver/solver_test.rs b/crates/shirabe/tests/dependency_resolver/solver_test.rs index 4f24003..c20fd4c 100644 --- a/crates/shirabe/tests/dependency_resolver/solver_test.rs +++ b/crates/shirabe/tests/dependency_resolver/solver_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/SolverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::{get_alias_package, get_package, get_version_constraint}; use indexmap::IndexMap; use shirabe::dependency_resolver::PolicyInterface; use shirabe::dependency_resolver::default_policy::DefaultPolicy; @@ -18,8 +16,8 @@ use shirabe::repository::handle::{LockArrayRepositoryHandle, RepositoryInterface use shirabe::repository::lock_array_repository::LockArrayRepository; use shirabe::repository::repository_set::RepositorySet; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint, MultiConstraint}; - -use crate::test_case::{get_alias_package, get_package, get_version_constraint}; +use std::cell::RefCell; +use std::rc::Rc; #[allow(dead_code)] struct Fixtures { diff --git a/crates/shirabe/tests/dependency_resolver/transaction_test.rs b/crates/shirabe/tests/dependency_resolver/transaction_test.rs index 7835e47..99f31c3 100644 --- a/crates/shirabe/tests/dependency_resolver/transaction_test.rs +++ b/crates/shirabe/tests/dependency_resolver/transaction_test.rs @@ -1,13 +1,12 @@ //! ref: composer/tests/Composer/Test/DependencyResolver/TransactionTest.php +use crate::test_case::{get_alias_package, get_package, get_version_constraint}; use indexmap::IndexMap; use shirabe::dependency_resolver::transaction::Transaction; use shirabe::package::Link; use shirabe::package::handle::PackageInterfaceHandle; use shirabe_php_shim::PhpMixed; -use crate::test_case::{get_alias_package, get_package, get_version_constraint}; - /// PHP `new Link($source, $target, $constraint, $type)`: prettyConstraint defaults to /// `(string) $constraint`. fn mk_link( diff --git a/crates/shirabe/tests/documentation_test.rs b/crates/shirabe/tests/documentation_test.rs index 4fe9a94..7dc049c 100644 --- a/crates/shirabe/tests/documentation_test.rs +++ b/crates/shirabe/tests/documentation_test.rs @@ -1,11 +1,10 @@ //! ref: composer/tests/Composer/Test/DocumentationTest.php -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::console::application::ApplicationHandle; use shirabe_external_packages::symfony::console::command::Command; use shirabe_external_packages::symfony::console::descriptor::application_description::ApplicationDescription; +use std::cell::RefCell; +use std::rc::Rc; fn get_command_name(command: &Rc<RefCell<dyn Command>>) -> String { let mut name = command.borrow().get_name().unwrap_or_default(); diff --git a/crates/shirabe/tests/downloader/archive_downloader_test.rs b/crates/shirabe/tests/downloader/archive_downloader_test.rs index 3543c2e..fedbae9 100644 --- a/crates/shirabe/tests/downloader/archive_downloader_test.rs +++ b/crates/shirabe/tests/downloader/archive_downloader_test.rs @@ -6,9 +6,6 @@ // real Config merged with `vendor-dir`, and real CompletePackage instances with dist // url/reference set. -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::downloader::FileDownloader; @@ -18,6 +15,8 @@ use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe::util::HttpDownloader; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; /// ref: TestCase::getPackage (default class CompletePackage) fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { diff --git a/crates/shirabe/tests/downloader/download_manager_test.rs b/crates/shirabe/tests/downloader/download_manager_test.rs index e18643e..3b259c8 100644 --- a/crates/shirabe/tests/downloader/download_manager_test.rs +++ b/crates/shirabe/tests/downloader/download_manager_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Downloader/DownloadManagerTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_stub::IOStub; use indexmap::IndexMap; use shirabe::downloader::DownloaderInterface; use shirabe::downloader::download_manager::DownloadManager; @@ -10,8 +8,8 @@ use shirabe::io::IOInterface; use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe_php_shim::{PhpMixed, RuntimeException}; use shirabe_semver::VersionParser; - -use crate::io_stub::IOStub; +use std::cell::RefCell; +use std::rc::Rc; // PHP mocks `Composer\Downloader\DownloaderInterface` with getMockBuilder. mockall::mock! { diff --git a/crates/shirabe/tests/downloader/file_downloader_test.rs b/crates/shirabe/tests/downloader/file_downloader_test.rs index 6f7025e..ead577e 100644 --- a/crates/shirabe/tests/downloader/file_downloader_test.rs +++ b/crates/shirabe/tests/downloader/file_downloader_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Downloader/FileDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::get_http_downloader_mock; +use crate::io_mock::{Expectation, get_io_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::cache::{Cache, CacheMock}; @@ -15,17 +14,16 @@ use shirabe::io::null_io::NullIO; use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe::util::HttpDownloader; use shirabe::util::filesystem::{Filesystem, FilesystemMock}; +use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::r#loop::Loop; use shirabe_php_shim::{ InvalidArgumentException, PhpMixed, RuntimeException, UnexpectedValueException, }; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::get_http_downloader_mock; -use crate::io_mock::{Expectation, get_io_mock}; -use shirabe::util::http_downloader::HttpDownloaderMockHandler; - /// ref: TestCase::getPackage (default class CompletePackage) fn get_package(name: &str, version: &str) -> PackageInterfaceHandle { let norm_version = VersionParser.normalize(version, None).unwrap(); diff --git a/crates/shirabe/tests/downloader/fossil_downloader_test.rs b/crates/shirabe/tests/downloader/fossil_downloader_test.rs index 2c47ac9..912b4b4 100644 --- a/crates/shirabe/tests/downloader/fossil_downloader_test.rs +++ b/crates/shirabe/tests/downloader/fossil_downloader_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Downloader/FossilDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::io_stub::IOStub; +use crate::process_executor_mock::get_process_executor_mock; use shirabe::config::Config; use shirabe::downloader::VcsDownloader; use shirabe::downloader::fossil_downloader::FossilDownloader; @@ -12,12 +12,10 @@ use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::{Filesystem, FilesystemMock}; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::config_stub::ConfigStubBuilder; -use crate::io_stub::IOStub; -use crate::process_executor_mock::get_process_executor_mock; - fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() .build() diff --git a/crates/shirabe/tests/downloader/git_downloader_test.rs b/crates/shirabe/tests/downloader/git_downloader_test.rs index 77a976e..7e98cae 100644 --- a/crates/shirabe/tests/downloader/git_downloader_test.rs +++ b/crates/shirabe/tests/downloader/git_downloader_test.rs @@ -1,8 +1,9 @@ //! ref: composer/tests/Composer/Test/Downloader/GitDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::io_mock::{Expectation, get_io_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::config::Config; @@ -17,13 +18,10 @@ use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::config_stub::ConfigStubBuilder; -use crate::io_mock::{Expectation, get_io_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; - fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() .build() diff --git a/crates/shirabe/tests/downloader/hg_downloader_test.rs b/crates/shirabe/tests/downloader/hg_downloader_test.rs index 28483f5..e68dfc5 100644 --- a/crates/shirabe/tests/downloader/hg_downloader_test.rs +++ b/crates/shirabe/tests/downloader/hg_downloader_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Downloader/HgDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_stub::IOStub; +use crate::process_executor_mock::{cmd, get_process_executor_mock}; use shirabe::config::Config; use shirabe::downloader::VcsDownloader; use shirabe::downloader::hg_downloader::HgDownloader; @@ -11,11 +10,10 @@ use shirabe::package::handle::{CompletePackageHandle, PackageInterfaceHandle}; use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::{Filesystem, FilesystemMock}; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{cmd, get_process_executor_mock}; - fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() .build() diff --git a/crates/shirabe/tests/downloader/perforce_downloader_test.rs b/crates/shirabe/tests/downloader/perforce_downloader_test.rs index f23888a..70f28e1 100644 --- a/crates/shirabe/tests/downloader/perforce_downloader_test.rs +++ b/crates/shirabe/tests/downloader/perforce_downloader_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Downloader/PerforceDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_mock::{Expectation, get_io_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::get_process_executor_mock; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::downloader::VcsDownloader; @@ -14,12 +14,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::io_mock::{Expectation, get_io_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::get_process_executor_mock; - // A getMockBuilder('Composer\Util\Perforce') stand-in: the seam trait extracted from the // concrete `Perforce` struct, mocked so the downloader's workflow can be verified. mockall::mock! { diff --git a/crates/shirabe/tests/downloader/xz_downloader_test.rs b/crates/shirabe/tests/downloader/xz_downloader_test.rs index d69e7cc..358f896 100644 --- a/crates/shirabe/tests/downloader/xz_downloader_test.rs +++ b/crates/shirabe/tests/downloader/xz_downloader_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Downloader/XzDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::downloader::DownloaderInterface; @@ -17,6 +14,8 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; /// ref: TestCase::getPackage (default class CompletePackage) diff --git a/crates/shirabe/tests/downloader/zip_downloader_test.rs b/crates/shirabe/tests/downloader/zip_downloader_test.rs index 055e98f..1d16f66 100644 --- a/crates/shirabe/tests/downloader/zip_downloader_test.rs +++ b/crates/shirabe/tests/downloader/zip_downloader_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Downloader/ZipDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_stub::IOStub; use serial_test::serial; use shirabe::config::Config; use shirabe::downloader::ArchiveDownloader; @@ -14,10 +12,10 @@ use shirabe::util::ProcessExecutor; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::{ZipArchive, ZipArchiveMock}; use shirabe_semver::VersionParser; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::io_stub::IOStub; - fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() .build() diff --git a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs index 9e048cf..cabb679 100644 --- a/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs +++ b/crates/shirabe/tests/event_dispatcher/event_dispatcher_test.rs @@ -1,11 +1,8 @@ //! ref: composer/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; - use shirabe::composer::{ComposerHandle, PartialOrFullComposer}; use shirabe::config::Config; use shirabe::dependency_resolver::Transaction; @@ -18,11 +15,10 @@ use shirabe::script::Event as ScriptEvent; use shirabe::script::ScriptEvents; use shirabe::util::platform::Platform; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; - use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PHP_EOL; - -use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; fn tear_down() { Platform::clear_env("COMPOSER_SKIP_SCRIPTS"); diff --git a/crates/shirabe/tests/factory_test.rs b/crates/shirabe/tests/factory_test.rs index c6464de..8685861 100644 --- a/crates/shirabe/tests/factory_test.rs +++ b/crates/shirabe/tests/factory_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/FactoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use serial_test::serial; use shirabe::factory::Factory; @@ -10,6 +7,8 @@ use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::platform::Platform; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[path = "common/config_stub.rs"] mod config_stub; diff --git a/crates/shirabe/tests/installer/binary_installer_test.rs b/crates/shirabe/tests/installer/binary_installer_test.rs index b26907d..6b3cae5 100644 --- a/crates/shirabe/tests/installer/binary_installer_test.rs +++ b/crates/shirabe/tests/installer/binary_installer_test.rs @@ -1,19 +1,16 @@ //! ref: composer/tests/Composer/Test/Installer/BinaryInstallerTest.php -use std::cell::RefCell; -use std::fs; -use std::rc::Rc; - +use crate::test_case::get_package; use base64::Engine; -use tempfile::TempDir; - use shirabe::installer::BinaryInstaller; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::Filesystem; use shirabe::util::ProcessExecutor; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::fs; +use std::rc::Rc; +use tempfile::TempDir; /// Mirror of setUp(): builds temp root/vendor/bin dirs plus a mocked IO. PHP uses a /// PHPUnit IOInterface mock with no expectations; a NullIO is the closest analogue. diff --git a/crates/shirabe/tests/installer/installation_manager_test.rs b/crates/shirabe/tests/installer/installation_manager_test.rs index 7480a02..bc1fcfd 100644 --- a/crates/shirabe/tests/installer/installation_manager_test.rs +++ b/crates/shirabe/tests/installer/installation_manager_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Installer/InstallationManagerTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::get_package; use shirabe::dependency_resolver::operation::{ InstallOperation, UninstallOperation, UpdateOperation, }; @@ -16,8 +14,8 @@ use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() diff --git a/crates/shirabe/tests/installer/installer_event_test.rs b/crates/shirabe/tests/installer/installer_event_test.rs index 8a85cab..b3bf14d 100644 --- a/crates/shirabe/tests/installer/installer_event_test.rs +++ b/crates/shirabe/tests/installer/installer_event_test.rs @@ -1,14 +1,13 @@ //! ref: composer/tests/Composer/Test/Installer/InstallerEventTest.php -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::composer::{ComposerHandle, PartialOrFullComposer}; use shirabe::dependency_resolver::Transaction; use shirabe::event_dispatcher::EventInterface; use shirabe::installer::InstallerEvent; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; +use std::cell::RefCell; +use std::rc::Rc; #[test] fn test_getter() { diff --git a/crates/shirabe/tests/installer/library_installer_test.rs b/crates/shirabe/tests/installer/library_installer_test.rs index b91ec51..44c7e5f 100644 --- a/crates/shirabe/tests/installer/library_installer_test.rs +++ b/crates/shirabe/tests/installer/library_installer_test.rs @@ -1,12 +1,7 @@ //! ref: composer/tests/Composer/Test/Installer/LibraryInstallerTest.php -use std::cell::RefCell; -use std::fs; -use std::rc::Rc; - +use crate::test_case::get_package; use indexmap::IndexMap; -use tempfile::TempDir; - use shirabe::composer::{ ComposerHandle, PartialComposerHandle, PartialComposerWeakHandle, PartialOrFullComposer, }; @@ -21,8 +16,10 @@ use shirabe::repository::RepositoryInterface; use shirabe::repository::WritableRepositoryInterface; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::fs; +use std::rc::Rc; +use tempfile::TempDir; // PHP mocks `Composer\Downloader\DownloadManager` with getMockBuilder and asserts its // install/update/remove calls; here the equivalent mock is injected into the Composer via diff --git a/crates/shirabe/tests/installer/metapackage_installer_test.rs b/crates/shirabe/tests/installer/metapackage_installer_test.rs index 20fe8ea..8528f6a 100644 --- a/crates/shirabe/tests/installer/metapackage_installer_test.rs +++ b/crates/shirabe/tests/installer/metapackage_installer_test.rs @@ -3,15 +3,13 @@ //! PHP verifies the mocked repository's add/remove/hasPackage calls; here the same //! behaviour is checked against a real InstalledArrayRepository by observing its state. -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::get_package; use shirabe::installer::{InstallerInterface, MetapackageInstaller}; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::repository::{InstalledArrayRepository, RepositoryInterface}; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; fn run<F: std::future::Future>(future: F) -> F::Output { tokio::runtime::Builder::new_current_thread() diff --git a/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs b/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs index fa3c8fb..1665085 100644 --- a/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs +++ b/crates/shirabe/tests/installer/suggested_packages_reporter_test.rs @@ -1,17 +1,15 @@ //! ref: composer/tests/Composer/Test/Installer/SuggestedPackagesReporterTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_mock::{Expectation, IOMock, IOMockGuard, get_io_mock}; +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::installer::SuggestedPackagesReporter; use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::io::null_io::NullIO; use shirabe::repository::{InstalledRepository, LockArrayRepository, RepositoryInterfaceHandle}; - -use crate::io_mock::{Expectation, IOMock, IOMockGuard, get_io_mock}; -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; /// ref: SuggestedPackagesReporterTest::setUp. /// diff --git a/crates/shirabe/tests/package/archiver/archive_manager_test.rs b/crates/shirabe/tests/package/archiver/archive_manager_test.rs index df83f56..68ee994 100644 --- a/crates/shirabe/tests/package/archiver/archive_manager_test.rs +++ b/crates/shirabe/tests/package/archiver/archive_manager_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Package/Archiver/ArchiveManagerTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::downloader::DownloadManager; @@ -14,6 +11,8 @@ use shirabe::package::handle::CompletePackageHandle; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe_php_shim::realpath; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; // ref: ArchiverTestCase::setUp + ArchiveManagerTest::setUp. diff --git a/crates/shirabe/tests/package/base_package_test.rs b/crates/shirabe/tests/package/base_package_test.rs index bd29eaa..d1bf432 100644 --- a/crates/shirabe/tests/package/base_package_test.rs +++ b/crates/shirabe/tests/package/base_package_test.rs @@ -1,13 +1,12 @@ //! ref: composer/tests/Composer/Test/Package/BasePackageTest.php +use crate::test_case::get_package; use shirabe::package::DisplayMode; use shirabe::package::base_package::package_names_to_regexp; use shirabe::package::handle::PackageHandle; use shirabe::repository::{ArrayRepository, RepositoryInterfaceHandle}; use shirabe_semver::VersionParser; -use crate::test_case::get_package; - fn empty_repository() -> RepositoryInterfaceHandle { RepositoryInterfaceHandle::new(ArrayRepository::new(vec![]).unwrap()) } diff --git a/crates/shirabe/tests/package/loader/root_package_loader_test.rs b/crates/shirabe/tests/package/loader/root_package_loader_test.rs index 93ee93a..6a13736 100644 --- a/crates/shirabe/tests/package/loader/root_package_loader_test.rs +++ b/crates/shirabe/tests/package/loader/root_package_loader_test.rs @@ -4,9 +4,7 @@ // ProcessExecutor / VersionGuesser or require constraints whose parsing goes through a // look-around regex the regex crate cannot compile. -use std::cell::RefCell; -use std::rc::Rc; - +use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::config::Config; @@ -23,8 +21,8 @@ use shirabe::util::Git as GitUtil; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; - -use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; fn null_io() -> Rc<RefCell<dyn IOInterface>> { Rc::new(RefCell::new(NullIO::new())) diff --git a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs index aeafefd..0acf768 100644 --- a/crates/shirabe/tests/package/loader/validating_array_loader_test.rs +++ b/crates/shirabe/tests/package/loader/validating_array_loader_test.rs @@ -1,12 +1,11 @@ //! ref: composer/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +use crate::test_case; use indexmap::IndexMap; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::package::loader::{InvalidPackageException, LoaderInterface, ValidatingArrayLoader}; use shirabe_php_shim::PhpMixed; -use crate::test_case; - fn s(v: &str) -> PhpMixed { PhpMixed::String(v.to_string()) } diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs index f70b79e..bbc333e 100644 --- a/crates/shirabe/tests/package/locker_test.rs +++ b/crates/shirabe/tests/package/locker_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Package/LockerTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::installer::InstallationManager; @@ -17,6 +14,8 @@ use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe::util::process_executor::ProcessExecutor; use shirabe_php_shim::{LogicException, PhpMixed, hash}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; fn null_io() -> Rc<RefCell<dyn IOInterface>> { diff --git a/crates/shirabe/tests/package/version/version_guesser_test.rs b/crates/shirabe/tests/package/version/version_guesser_test.rs index 6bfe6c1..1a3f23c 100644 --- a/crates/shirabe/tests/package/version/version_guesser_test.rs +++ b/crates/shirabe/tests/package/version/version_guesser_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Package/Version/VersionGuesserTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::config::Config; @@ -11,8 +9,8 @@ use shirabe::util::Git as GitUtil; use shirabe::util::platform::Platform; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; - -use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; // Mirrors VersionGuesserTest::setUp/tearDown: reset GitUtil's cached `version` // static so each test re-runs `git --version` against its own mock. diff --git a/crates/shirabe/tests/package/version/version_selector_test.rs b/crates/shirabe/tests/package/version/version_selector_test.rs index 8e0912e..3a0c701 100644 --- a/crates/shirabe/tests/package/version/version_selector_test.rs +++ b/crates/shirabe/tests/package/version/version_selector_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Package/Version/VersionSelectorTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::filter::platform_requirement_filter::PlatformRequirementFilterFactory; use shirabe::io::BufferIO; @@ -17,13 +15,12 @@ use shirabe::package::version::VersionSelector; use shirabe::package::version::version_parser::VersionParser; use shirabe::repository::PlatformRepository; use shirabe::repository::RepositorySetInterface; +use shirabe_external_packages::symfony::console::output::output_interface; use shirabe_php_shim::PhpMixed; use shirabe_php_shim::{PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION}; use shirabe_semver::constraint::AnyConstraint; - -use shirabe_external_packages::symfony::console::output::output_interface; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; mockall::mock! { RepositorySet {} diff --git a/crates/shirabe/tests/question/strict_confirmation_question_test.rs b/crates/shirabe/tests/question/strict_confirmation_question_test.rs index de8911b..d8606eb 100644 --- a/crates/shirabe/tests/question/strict_confirmation_question_test.rs +++ b/crates/shirabe/tests/question/strict_confirmation_question_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Question/StrictConfirmationQuestionTest.php -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::question::StrictConfirmationQuestion; use shirabe_external_packages::symfony::console::helper::question_helper::QuestionHelper; use shirabe_external_packages::symfony::console::input::array_input::ArrayInput; @@ -10,6 +7,8 @@ use shirabe_external_packages::symfony::console::input::streamable_input_interfa use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface; use shirabe_external_packages::symfony::console::output::stream_output::StreamOutput; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; const TRUE_ANSWER_REGEX: &str = "/^y(?:es)?$/i"; const FALSE_ANSWER_REGEX: &str = "/^no?$/i"; diff --git a/crates/shirabe/tests/repository/array_repository_test.rs b/crates/shirabe/tests/repository/array_repository_test.rs index 1612b7c..ae6725d 100644 --- a/crates/shirabe/tests/repository/array_repository_test.rs +++ b/crates/shirabe/tests/repository/array_repository_test.rs @@ -1,5 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/ArrayRepositoryTest.php +use crate::test_case::{get_alias_package, get_package}; use indexmap::IndexMap; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::package::loader::array_loader::ArrayLoader; @@ -8,8 +9,6 @@ use shirabe::repository::{ }; use shirabe_php_shim::PhpMixed; -use crate::test_case::{get_alias_package, get_package}; - /// PHP `setType`/`setAbandoned` operate on non-root packages; the public handle API only allows /// such setters on root packages, so packages carrying extra config are built via ArrayLoader. fn loaded(name: &str, version: &str, extra: Vec<(&str, PhpMixed)>) -> PackageInterfaceHandle { diff --git a/crates/shirabe/tests/repository/artifact_repository_test.rs b/crates/shirabe/tests/repository/artifact_repository_test.rs index 90e5625..558ee8b 100644 --- a/crates/shirabe/tests/repository/artifact_repository_test.rs +++ b/crates/shirabe/tests/repository/artifact_repository_test.rs @@ -1,12 +1,11 @@ //! ref: composer/tests/Composer/Test/Repository/ArtifactRepositoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::io::{IOInterface, NullIO}; use shirabe::repository::ArtifactRepository; use shirabe_php_shim::{PhpMixed, extension_loaded}; +use std::cell::RefCell; +use std::rc::Rc; /// Returns true when the test should be skipped because the zip extension is /// unavailable, mirroring PHP's markTestSkipped in setUp. diff --git a/crates/shirabe/tests/repository/composer_repository_test.rs b/crates/shirabe/tests/repository/composer_repository_test.rs index ae82b24..8e5a7f1 100644 --- a/crates/shirabe/tests/repository/composer_repository_test.rs +++ b/crates/shirabe/tests/repository/composer_repository_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/ComposerRepositoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -13,10 +11,10 @@ use shirabe::repository::composer_repository::{ComposerRepository, ProviderListi use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe_php_shim::PhpMixed; use shirabe_semver::constraint::{AnyConstraint, SimpleConstraint}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; - // Mirrors PHP's `['url' => .., 'body' => ..]` mock entry (status defaults to 200, // options match any executed options). fn http_body( diff --git a/crates/shirabe/tests/repository/composite_repository_test.rs b/crates/shirabe/tests/repository/composite_repository_test.rs index eed01f6..5fa0fb8 100644 --- a/crates/shirabe/tests/repository/composite_repository_test.rs +++ b/crates/shirabe/tests/repository/composite_repository_test.rs @@ -1,13 +1,12 @@ //! ref: composer/tests/Composer/Test/Repository/CompositeRepositoryTest.php +use crate::test_case::get_package; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::repository::{ ArrayRepository, CompositeRepository, FindPackageConstraint, RepositoryInterface, RepositoryInterfaceHandle, SEARCH_FULLTEXT, }; -use crate::test_case::get_package; - fn array_repo(packages: Vec<PackageInterfaceHandle>) -> RepositoryInterfaceHandle { RepositoryInterfaceHandle::new(ArrayRepository::new(packages).unwrap()) } diff --git a/crates/shirabe/tests/repository/filesystem_repository_test.rs b/crates/shirabe/tests/repository/filesystem_repository_test.rs index 7459486..e8bdddb 100644 --- a/crates/shirabe/tests/repository/filesystem_repository_test.rs +++ b/crates/shirabe/tests/repository/filesystem_repository_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/FilesystemRepositoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::{get_alias_package, get_package}; use indexmap::IndexMap; use shirabe::dependency_resolver::operation::OperationInterface; use shirabe::installed_versions::InstalledVersions; @@ -17,8 +15,8 @@ use shirabe::repository::filesystem_repository::FilesystemRepository; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; use shirabe_semver::VersionParser; - -use crate::test_case::{get_alias_package, get_package}; +use std::cell::RefCell; +use std::rc::Rc; /// PHP mocks JsonFile::read()/exists(); without a mocking framework the canned read value is /// materialized as a real temp file whose decoded JSON reproduces the mock return value exactly. diff --git a/crates/shirabe/tests/repository/filter_repository_test.rs b/crates/shirabe/tests/repository/filter_repository_test.rs index a244f52..4a6c112 100644 --- a/crates/shirabe/tests/repository/filter_repository_test.rs +++ b/crates/shirabe/tests/repository/filter_repository_test.rs @@ -1,5 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/FilterRepositoryTest.php +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::package::base_package::STABILITIES; use shirabe::repository::{ @@ -8,8 +9,6 @@ use shirabe::repository::{ }; use shirabe_semver::constraint::{AnyConstraint, MatchAllConstraint}; -use crate::test_case::get_package; - fn set_up() -> RepositoryInterfaceHandle { let repo = ArrayRepository::new(vec![ get_package("foo/aaa", "1.0.0"), diff --git a/crates/shirabe/tests/repository/installed_repository_test.rs b/crates/shirabe/tests/repository/installed_repository_test.rs index ec56b5f..5aa85e9 100644 --- a/crates/shirabe/tests/repository/installed_repository_test.rs +++ b/crates/shirabe/tests/repository/installed_repository_test.rs @@ -1,5 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/InstalledRepositoryTest.php +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::package::loader::array_loader::ArrayLoader; @@ -9,8 +10,6 @@ use shirabe::repository::{ }; use shirabe_php_shim::PhpMixed; -use crate::test_case::get_package; - /// PHP `setReplaces`/`setProvides` operate on non-root packages; the public handle API only allows /// link setters on root packages, so packages carrying links are built via ArrayLoader. fn loaded(name: &str, version: &str, extra: Vec<(&str, PhpMixed)>) -> PackageInterfaceHandle { diff --git a/crates/shirabe/tests/repository/path_repository_test.rs b/crates/shirabe/tests/repository/path_repository_test.rs index bbf4938..f86d659 100644 --- a/crates/shirabe/tests/repository/path_repository_test.rs +++ b/crates/shirabe/tests/repository/path_repository_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/PathRepositoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::test_case::get_package; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::{IOInterface, NullIO}; @@ -13,8 +11,8 @@ use shirabe::util::{Platform, ProcessExecutor}; use shirabe_php_shim::{ DIRECTORY_SEPARATOR, PhpMixed, file_get_contents, hash, realpath, serialize, }; - -use crate::test_case::get_package; +use std::cell::RefCell; +use std::rc::Rc; fn fixtures_dir() -> String { format!( diff --git a/crates/shirabe/tests/repository/repository_factory_test.rs b/crates/shirabe/tests/repository/repository_factory_test.rs index b1a9001..ef52380 100644 --- a/crates/shirabe/tests/repository/repository_factory_test.rs +++ b/crates/shirabe/tests/repository/repository_factory_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Repository/RepositoryFactoryTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -10,6 +7,8 @@ use shirabe::io::null_io::NullIO; use shirabe::repository::RepositoryFactory; use shirabe::util::http_downloader::HttpDownloader; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; #[test] fn test_manager_with_all_repository_types() { diff --git a/crates/shirabe/tests/repository/repository_manager_test.rs b/crates/shirabe/tests/repository/repository_manager_test.rs index 732b598..089ce9a 100644 --- a/crates/shirabe/tests/repository/repository_manager_test.rs +++ b/crates/shirabe/tests/repository/repository_manager_test.rs @@ -4,9 +4,6 @@ // curl_multi_init, todo!()) with a mocked IO/Config/EventDispatcher and exercise repo // creation/prepending/wrapping. -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -15,6 +12,8 @@ use shirabe::repository::{ArrayRepository, RepositoryInterfaceHandle, Repository use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloader; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; struct SetUp { diff --git a/crates/shirabe/tests/repository/repository_utils_test.rs b/crates/shirabe/tests/repository/repository_utils_test.rs index 1c690e9..a53bb37 100644 --- a/crates/shirabe/tests/repository/repository_utils_test.rs +++ b/crates/shirabe/tests/repository/repository_utils_test.rs @@ -1,13 +1,12 @@ //! ref: composer/tests/Composer/Test/Repository/RepositoryUtilsTest.php +use crate::test_case::{get_alias_package, get_package}; use indexmap::IndexMap; use shirabe::package::handle::PackageInterfaceHandle; use shirabe::package::loader::array_loader::ArrayLoader; use shirabe::repository::RepositoryUtils; use shirabe_php_shim::PhpMixed; -use crate::test_case::{get_alias_package, get_package}; - /// PHP `configureLinks` sets link arrays on non-root packages; the public handle API only allows /// link setters on root packages, so packages carrying links are built via ArrayLoader. fn load_with( diff --git a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs index 2e36833..296309f 100644 --- a/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/forgejo_driver_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/ForgejoDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; +use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,11 +11,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; -use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; - struct SetUp { home: TempDir, config: Rc<RefCell<Config>>, diff --git a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs index a3986c2..1a5a425 100644 --- a/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/fossil_driver_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/FossilDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -10,6 +7,8 @@ use shirabe::io::null_io::NullIO; use shirabe::repository::vcs::FossilDriver; use shirabe::util::filesystem::Filesystem; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; struct SetUp { diff --git a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs index 5bf3ee4..124d529 100644 --- a/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/git_bitbucket_driver_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/GitBitbucketDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; +use crate::io_stub::IOStub; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,11 +11,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::ProcessExecutor; use shirabe_php_shim::{InvalidArgumentException, PhpMixed, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; -use crate::io_stub::IOStub; - struct SetUp { home: TempDir, config: Config, diff --git a/crates/shirabe/tests/repository/vcs/git_driver_test.rs b/crates/shirabe/tests/repository/vcs/git_driver_test.rs index 7c30b21..be26dd1 100644 --- a/crates/shirabe/tests/repository/vcs/git_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/git_driver_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/GitDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::config::Config; @@ -13,12 +13,10 @@ use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::platform::Platform; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; - struct SetUp { home: TempDir, config: Config, diff --git a/crates/shirabe/tests/repository/vcs/github_driver_test.rs b/crates/shirabe/tests/repository/vcs/github_driver_test.rs index f1084f5..11da393 100644 --- a/crates/shirabe/tests/repository/vcs/github_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/github_driver_test.rs @@ -1,8 +1,10 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/GitHubDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{ + ProcessExecutorMockGuard, cmd, cmd_full, get_process_executor_mock, +}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::config::ConfigSourceInterface; @@ -13,14 +15,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{ - ProcessExecutorMockGuard, cmd, cmd_full, get_process_executor_mock, -}; - struct SetUp { home: TempDir, config: Config, diff --git a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs index 437617b..f364863 100644 --- a/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/gitlab_driver_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/GitLabDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; +use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -11,9 +10,8 @@ use shirabe::repository::vcs::GitLabDriver; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::{PhpMixed, extension_loaded}; - -use crate::http_downloader_mock::{HttpDownloaderMockGuard, expect_full, get_http_downloader_mock}; -use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; // Mirrors GitLabDriverTest::setUp's `gitlab-domains` configuration. fn make_config() -> Config { diff --git a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs index f00cb9d..5e16c67 100644 --- a/crates/shirabe/tests/repository/vcs/hg_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/hg_driver_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/HgDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,12 +12,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; - struct SetUp { home: TempDir, config: Config, diff --git a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs index ef55c75..13b36a3 100644 --- a/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/perforce_driver_test.rs @@ -1,8 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,10 +10,10 @@ use shirabe::util::HttpDownloader; use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::process_executor_mock::{ProcessExecutorMockGuard, get_process_executor_mock}; - const TEST_URL: &str = "TEST_PERFORCE_URL"; const TEST_DEPOT: &str = "TEST_DEPOT_CONFIG"; const TEST_BRANCH: &str = "TEST_BRANCH_CONFIG"; diff --git a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs index a1e79fc..70eeead 100644 --- a/crates/shirabe/tests/repository/vcs/svn_driver_test.rs +++ b/crates/shirabe/tests/repository/vcs/svn_driver_test.rs @@ -1,8 +1,8 @@ //! ref: composer/tests/Composer/Test/Repository/Vcs/SvnDriverTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -12,12 +12,10 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, RuntimeException}; +use std::cell::RefCell; +use std::rc::Rc; use tempfile::TempDir; -use crate::http_downloader_mock::{HttpDownloaderMockGuard, get_http_downloader_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{ProcessExecutorMockGuard, cmd_full, get_process_executor_mock}; - struct SetUp { home: TempDir, config: Config, diff --git a/crates/shirabe/tests/repository/vcs_repository_test.rs b/crates/shirabe/tests/repository/vcs_repository_test.rs index e3b0e84..ed705e8 100644 --- a/crates/shirabe/tests/repository/vcs_repository_test.rs +++ b/crates/shirabe/tests/repository/vcs_repository_test.rs @@ -1,11 +1,6 @@ //! ref: composer/tests/Composer/Test/Repository/VcsRepositoryTest.php -use std::cell::RefCell; -use std::collections::HashSet; -use std::process::Command; -use std::rc::Rc; - -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use serial_test::serial; use shirabe::config::Config; use shirabe::io::IOInterface; @@ -16,6 +11,9 @@ use shirabe::util::filesystem::Filesystem; use shirabe::util::http_downloader::HttpDownloader; use shirabe::util::r#loop::Loop; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::process::Command; +use std::rc::Rc; use tempfile::TempDir; struct SetUp { @@ -175,7 +173,7 @@ fn test_load_versions() { let composer_home = set_up.composer_home.path().to_path_buf(); let git_repo = set_up.git_repo.path().to_path_buf(); - let mut expected: HashSet<String> = [ + let mut expected: IndexSet<String> = [ "0.6.0", "1.0.0", "1.0.x-dev", @@ -238,7 +236,11 @@ fn test_load_versions() { for package in &packages { let pretty = package.get_pretty_version(); - assert!(expected.remove(&pretty), "Unexpected version {}", pretty); + assert!( + expected.shift_remove(&pretty), + "Unexpected version {}", + pretty + ); } assert!( diff --git a/crates/shirabe/tests/script/event_test.rs b/crates/shirabe/tests/script/event_test.rs index d143bd2..e249269 100644 --- a/crates/shirabe/tests/script/event_test.rs +++ b/crates/shirabe/tests/script/event_test.rs @@ -1,8 +1,5 @@ //! ref: composer/tests/Composer/Test/Script/EventTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::composer::{ComposerHandle, PartialOrFullComposer}; use shirabe::config::Config; @@ -12,6 +9,8 @@ use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::package::{RootPackageHandle, RootPackageInterfaceHandle}; use shirabe::script::{Event, OriginatingEvent}; +use std::cell::RefCell; +use std::rc::Rc; fn create_composer_instance() -> ComposerHandle { let composer = diff --git a/crates/shirabe/tests/util/auth_helper_test.rs b/crates/shirabe/tests/util/auth_helper_test.rs index 7738afb..905cbf7 100644 --- a/crates/shirabe/tests/util/auth_helper_test.rs +++ b/crates/shirabe/tests/util/auth_helper_test.rs @@ -1,17 +1,15 @@ //! ref: composer/tests/Composer/Test/Util/AuthHelperTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::io_mock::{Expectation, IOMock, get_io_mock}; use indexmap::IndexMap; use shirabe::config::ConfigSourceInterface; use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::{AuthHelper, Bitbucket, StoreAuth}; use shirabe_php_shim::{PhpMixed, base64_encode, json_encode}; - -use crate::config_stub::ConfigStubBuilder; -use crate::io_mock::{Expectation, IOMock, get_io_mock}; +use std::cell::RefCell; +use std::rc::Rc; // Mirrors AuthHelperTest::setUp: a DEBUG-verbosity IOMock plus a real Config, both // shared with the AuthHelper under test. The IOMockGuard runs assert_complete on drop. diff --git a/crates/shirabe/tests/util/bitbucket_test.rs b/crates/shirabe/tests/util/bitbucket_test.rs index 2817266..db45b3e 100644 --- a/crates/shirabe/tests/util/bitbucket_test.rs +++ b/crates/shirabe/tests/util/bitbucket_test.rs @@ -1,8 +1,9 @@ //! ref: composer/tests/Composer/Test/Util/BitbucketTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; +use crate::io_mock::{Expectation, IOMock, get_io_mock}; +use crate::process_executor_mock::get_process_executor_mock; use indexmap::IndexMap; use shirabe::config::{Config, ConfigSourceInterface}; use shirabe::io::IOInterface; @@ -13,11 +14,8 @@ use shirabe::util::http_downloader::{ }; use shirabe::util::process_executor::MockHandler; use shirabe_php_shim::{PhpMixed, time}; - -use crate::config_stub::ConfigStubBuilder; -use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; -use crate::io_mock::{Expectation, IOMock, get_io_mock}; -use crate::process_executor_mock::get_process_executor_mock; +use std::cell::RefCell; +use std::rc::Rc; const USERNAME: &str = "username"; const PASSWORD: &str = "password"; diff --git a/crates/shirabe/tests/util/config_validator_test.rs b/crates/shirabe/tests/util/config_validator_test.rs index 94e5792..6d7aaf8 100644 --- a/crates/shirabe/tests/util/config_validator_test.rs +++ b/crates/shirabe/tests/util/config_validator_test.rs @@ -1,12 +1,11 @@ //! ref: composer/tests/Composer/Test/Util/ConfigValidatorTest.php -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::io::io_interface::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::package::loader::validating_array_loader::ValidatingArrayLoader; use shirabe::util::config_validator::ConfigValidator; +use std::cell::RefCell; +use std::rc::Rc; fn fixture(name: &str) -> String { format!( diff --git a/crates/shirabe/tests/util/forgejo_test.rs b/crates/shirabe/tests/util/forgejo_test.rs index a1a8f9c..106cdab 100644 --- a/crates/shirabe/tests/util/forgejo_test.rs +++ b/crates/shirabe/tests/util/forgejo_test.rs @@ -1,18 +1,16 @@ //! ref: composer/tests/Composer/Test/Util/ForgejoTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; +use crate::io_mock::{Expectation, IOMock, get_io_mock}; use shirabe::config::{Config, ConfigSourceInterface}; use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::Forgejo; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe_php_shim::PhpMixed; - -use crate::config_stub::ConfigStubBuilder; -use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; -use crate::io_mock::{Expectation, IOMock, get_io_mock}; +use std::cell::RefCell; +use std::rc::Rc; const USERNAME: &str = "username"; const ACCESS_TOKEN: &str = "access-token"; diff --git a/crates/shirabe/tests/util/git_test.rs b/crates/shirabe/tests/util/git_test.rs index 80037da..43af80a 100644 --- a/crates/shirabe/tests/util/git_test.rs +++ b/crates/shirabe/tests/util/git_test.rs @@ -1,8 +1,9 @@ //! ref: composer/tests/Composer/Test/Util/GitTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; +use crate::io_stub::IOStub; +use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use shirabe::config::{Config, ConfigSourceInterface}; use shirabe::io::IOInterface; @@ -11,11 +12,8 @@ use shirabe::util::git::Git; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe::util::process_executor::{MockExpectation, MockHandler, ProcessExecutor}; use shirabe_php_shim::{PhpMixed, RuntimeException}; - -use crate::config_stub::ConfigStubBuilder; -use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; -use crate::io_stub::IOStub; -use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; // No-op ConfigSourceInterface, equivalent to PHPUnit's // `getMockBuilder(Config::class)` auto-stubbing getConfigSource/getAuthConfigSource: diff --git a/crates/shirabe/tests/util/github_test.rs b/crates/shirabe/tests/util/github_test.rs index 0069a9c..b9abeb2 100644 --- a/crates/shirabe/tests/util/github_test.rs +++ b/crates/shirabe/tests/util/github_test.rs @@ -1,18 +1,16 @@ //! ref: composer/tests/Composer/Test/Util/GitHubTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; +use crate::io_mock::{Expectation, IOMock, get_io_mock}; use shirabe::config::{Config, ConfigSourceInterface}; use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::GitHub; use shirabe::util::http_downloader::{HttpDownloader, HttpDownloaderMockHandler}; use shirabe_php_shim::PhpMixed; - -use crate::config_stub::ConfigStubBuilder; -use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; -use crate::io_mock::{Expectation, IOMock, get_io_mock}; +use std::cell::RefCell; +use std::rc::Rc; const PASSWORD: &str = "password"; const MESSAGE: &str = "mymessage"; diff --git a/crates/shirabe/tests/util/gitlab_test.rs b/crates/shirabe/tests/util/gitlab_test.rs index a3db85b..46c0358 100644 --- a/crates/shirabe/tests/util/gitlab_test.rs +++ b/crates/shirabe/tests/util/gitlab_test.rs @@ -1,18 +1,16 @@ //! ref: composer/tests/Composer/Test/Util/GitLabTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; +use crate::io_mock::{Expectation, IOMock, get_io_mock}; use shirabe::config::{Config, ConfigSourceInterface}; use shirabe::io::IOInterface; use shirabe::io::io_interface; use shirabe::util::GitLab; use shirabe::util::http_downloader::HttpDownloaderMockHandler; use shirabe_php_shim::PhpMixed; - -use crate::config_stub::ConfigStubBuilder; -use crate::http_downloader_mock::{expect_full, get_http_downloader_mock}; -use crate::io_mock::{Expectation, IOMock, get_io_mock}; +use std::cell::RefCell; +use std::rc::Rc; const USERNAME: &str = "username"; const PASSWORD: &str = "password"; diff --git a/crates/shirabe/tests/util/http_downloader_test.rs b/crates/shirabe/tests/util/http_downloader_test.rs index 078fd57..b184184 100644 --- a/crates/shirabe/tests/util/http_downloader_test.rs +++ b/crates/shirabe/tests/util/http_downloader_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Util/HttpDownloaderTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::io_mock::{Expectation, get_io_mock}; use indexmap::IndexMap; use shirabe::config::Config; use shirabe::downloader::TransportException; @@ -13,9 +12,8 @@ use shirabe::util::Platform; use shirabe::util::http_downloader::HttpDownloader; use shirabe_external_packages::symfony::console::output::output_interface::VERBOSITY_NORMAL; use shirabe_php_shim::{PHP_EOL, PhpMixed}; - -use crate::config_stub::ConfigStubBuilder; -use crate::io_mock::{Expectation, get_io_mock}; +use std::cell::RefCell; +use std::rc::Rc; // PHP performs a live HTTP get to assert the URL's user:pass is captured via // setAuthentication. The credential capture happens in `add_job`, before any diff --git a/crates/shirabe/tests/util/perforce_test.rs b/crates/shirabe/tests/util/perforce_test.rs index 482094f..b6f8f11 100644 --- a/crates/shirabe/tests/util/perforce_test.rs +++ b/crates/shirabe/tests/util/perforce_test.rs @@ -1,8 +1,7 @@ //! ref: composer/tests/Composer/Test/Util/PerforceTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::io_stub::IOStub; +use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; use indexmap::IndexMap; use serial_test::serial; use shirabe::io::{IOInterface, NullIO}; @@ -10,9 +9,8 @@ use shirabe::util::Perforce; use shirabe::util::filesystem::Filesystem; use shirabe::util::process_executor::{MockHandler, ProcessExecutor}; use shirabe_php_shim::PhpMixed; - -use crate::io_stub::IOStub; -use crate::process_executor_mock::{cmd, cmd_full, get_process_executor_mock}; +use std::cell::RefCell; +use std::rc::Rc; const TEST_DEPOT: &str = "depot"; const TEST_BRANCH: &str = "branch"; diff --git a/crates/shirabe/tests/util/process_executor_test.rs b/crates/shirabe/tests/util/process_executor_test.rs index 01e37ed..78c5f9f 100644 --- a/crates/shirabe/tests/util/process_executor_test.rs +++ b/crates/shirabe/tests/util/process_executor_test.rs @@ -4,9 +4,6 @@ // password hiding, line splitting and argument escaping; the subprocess execution and mocked // IO are not ported. -use std::cell::RefCell; -use std::rc::Rc; - use shirabe::io::ConsoleIO; use shirabe::io::IOInterface; use shirabe::io::buffer_io::BufferIO; @@ -19,6 +16,8 @@ use shirabe_external_packages::symfony::console::output::output_interface::{ OutputInterface, VERBOSITY_DEBUG, VERBOSITY_NORMAL, }; use shirabe_php_shim::{PHP_EOL, trim}; +use std::cell::RefCell; +use std::rc::Rc; #[test] fn test_execute_captures_output() { diff --git a/crates/shirabe/tests/util/remote_filesystem_test.rs b/crates/shirabe/tests/util/remote_filesystem_test.rs index a5d9d66..ba79757 100644 --- a/crates/shirabe/tests/util/remote_filesystem_test.rs +++ b/crates/shirabe/tests/util/remote_filesystem_test.rs @@ -1,15 +1,13 @@ //! ref: composer/tests/Composer/Test/Util/RemoteFilesystemTest.php -use std::cell::RefCell; -use std::rc::Rc; - +use crate::config_stub::ConfigStubBuilder; +use crate::io_stub::IOStub; use indexmap::IndexMap; use shirabe::io::IOInterface; use shirabe::util::RemoteFilesystem; use shirabe_php_shim::{PhpMixed, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, strpos}; - -use crate::config_stub::ConfigStubBuilder; -use crate::io_stub::IOStub; +use std::cell::RefCell; +use std::rc::Rc; // Mirrors RemoteFilesystemTest::getConfigMock: get('github-domains') and // get('gitlab-domains') return [], everything else returns null. add_authentication_options diff --git a/crates/shirabe/tests/util/svn_test.rs b/crates/shirabe/tests/util/svn_test.rs index 7a30d8b..f700634 100644 --- a/crates/shirabe/tests/util/svn_test.rs +++ b/crates/shirabe/tests/util/svn_test.rs @@ -1,14 +1,13 @@ //! ref: composer/tests/Composer/Test/Util/SvnTest.php -use std::cell::RefCell; -use std::rc::Rc; - use indexmap::IndexMap; use shirabe::config::Config; use shirabe::io::IOInterface; use shirabe::io::null_io::NullIO; use shirabe::util::svn::Svn; use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::rc::Rc; fn map(pairs: Vec<(&str, PhpMixed)>) -> IndexMap<String, PhpMixed> { pairs.into_iter().map(|(k, v)| (k.to_string(), v)).collect() |
