From 53f1fb395f33e0fb8db9aebd09ea9082f650f9f1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 17:45:06 +0900 Subject: refactor: add linter --- crates/shirabe-external-packages/src/composer.rs | 7 + .../src/composer/ca_bundle.rs | 3 + .../src/composer/ca_bundle/mod.rs | 3 - .../shirabe-external-packages/src/composer/mod.rs | 7 - .../shirabe-external-packages/src/composer/pcre.rs | 3 + .../src/composer/pcre/mod.rs | 3 - .../src/composer/pcre/preg.rs | 3 +- .../src/composer/xdebug_handler.rs | 3 + .../src/composer/xdebug_handler/mod.rs | 3 - crates/shirabe-external-packages/src/psr.rs | 3 + crates/shirabe-external-packages/src/psr/log.rs | 5 + .../shirabe-external-packages/src/psr/log/mod.rs | 5 - crates/shirabe-external-packages/src/psr/mod.rs | 3 - crates/shirabe-external-packages/src/seld.rs | 5 + .../src/seld/json_lint.rs | 9 + .../src/seld/json_lint/json_parser.rs | 25 +-- .../src/seld/json_lint/mod.rs | 9 - crates/shirabe-external-packages/src/seld/mod.rs | 5 - .../shirabe-external-packages/src/seld/signal.rs | 3 + .../src/seld/signal/mod.rs | 3 - crates/shirabe-external-packages/src/symfony.rs | 5 + .../src/symfony/console.rs | 35 +++ .../src/symfony/console/attribute.rs | 3 + .../src/symfony/console/attribute/mod.rs | 3 - .../src/symfony/console/command.rs | 13 ++ .../symfony/console/command/complete_command.rs | 11 +- .../src/symfony/console/command/mod.rs | 13 -- .../src/symfony/console/command_loader.rs | 3 + .../src/symfony/console/command_loader/mod.rs | 3 - .../src/symfony/console/completion.rs | 9 + .../symfony/console/completion/completion_input.rs | 3 +- .../src/symfony/console/completion/mod.rs | 9 - .../src/symfony/console/completion/output.rs | 5 + .../src/symfony/console/completion/output/mod.rs | 5 - .../src/symfony/console/descriptor.rs | 15 ++ .../src/symfony/console/descriptor/mod.rs | 15 -- .../src/symfony/console/exception.rs | 17 ++ .../src/symfony/console/exception/mod.rs | 17 -- .../src/symfony/console/formatter.rs | 13 ++ .../src/symfony/console/formatter/mod.rs | 13 -- .../src/symfony/console/helper.rs | 33 +++ .../console/helper/debug_formatter_helper.rs | 2 +- .../src/symfony/console/helper/formatter_helper.rs | 4 +- .../src/symfony/console/helper/mod.rs | 33 --- .../src/symfony/console/input.rs | 21 ++ .../src/symfony/console/input/argv_input.rs | 4 +- .../src/symfony/console/input/array_input.rs | 2 +- .../src/symfony/console/input/input_definition.rs | 4 +- .../src/symfony/console/input/mod.rs | 21 -- .../src/symfony/console/mod.rs | 35 --- .../src/symfony/console/output.rs | 17 ++ .../src/symfony/console/output/mod.rs | 17 -- .../src/symfony/console/question.rs | 7 + .../src/symfony/console/question/mod.rs | 7 - .../src/symfony/console/signal_registry.rs | 3 + .../src/symfony/console/signal_registry/mod.rs | 3 - .../src/symfony/console/style.rs | 7 + .../src/symfony/console/style/mod.rs | 7 - .../src/symfony/filesystem.rs | 5 + .../src/symfony/filesystem/exception.rs | 3 + .../src/symfony/filesystem/exception/mod.rs | 3 - .../src/symfony/filesystem/mod.rs | 5 - .../src/symfony/finder.rs | 7 + .../src/symfony/finder/finder.rs | 11 +- .../src/symfony/finder/mod.rs | 7 - .../shirabe-external-packages/src/symfony/mod.rs | 5 - .../src/symfony/process.rs | 13 ++ .../src/symfony/process/exception.rs | 13 ++ .../src/symfony/process/exception/mod.rs | 13 -- .../src/symfony/process/executable_finder.rs | 66 +++--- .../src/symfony/process/mod.rs | 13 -- .../src/symfony/process/php_executable_finder.rs | 7 +- .../src/symfony/process/pipes.rs | 9 + .../src/symfony/process/pipes/abstract_pipes.rs | 15 +- .../src/symfony/process/pipes/mod.rs | 9 - .../src/symfony/process/pipes/unix_pipes.rs | 16 +- .../src/symfony/process/pipes/windows_pipes.rs | 5 +- .../src/symfony/process/process.rs | 235 ++++++++++++--------- .../src/symfony/process/process_utils.rs | 7 +- .../src/symfony/string.rs | 17 ++ .../src/symfony/string/mod.rs | 17 -- 81 files changed, 543 insertions(+), 505 deletions(-) create mode 100644 crates/shirabe-external-packages/src/composer.rs create mode 100644 crates/shirabe-external-packages/src/composer/ca_bundle.rs delete mode 100644 crates/shirabe-external-packages/src/composer/ca_bundle/mod.rs delete mode 100644 crates/shirabe-external-packages/src/composer/mod.rs create mode 100644 crates/shirabe-external-packages/src/composer/pcre.rs delete mode 100644 crates/shirabe-external-packages/src/composer/pcre/mod.rs create mode 100644 crates/shirabe-external-packages/src/composer/xdebug_handler.rs delete mode 100644 crates/shirabe-external-packages/src/composer/xdebug_handler/mod.rs create mode 100644 crates/shirabe-external-packages/src/psr.rs create mode 100644 crates/shirabe-external-packages/src/psr/log.rs delete mode 100644 crates/shirabe-external-packages/src/psr/log/mod.rs delete mode 100644 crates/shirabe-external-packages/src/psr/mod.rs create mode 100644 crates/shirabe-external-packages/src/seld.rs create mode 100644 crates/shirabe-external-packages/src/seld/json_lint.rs delete mode 100644 crates/shirabe-external-packages/src/seld/json_lint/mod.rs delete mode 100644 crates/shirabe-external-packages/src/seld/mod.rs create mode 100644 crates/shirabe-external-packages/src/seld/signal.rs delete mode 100644 crates/shirabe-external-packages/src/seld/signal/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/attribute.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/attribute/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/command.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/command/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/command_loader.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/command_loader/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/completion.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/completion/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/completion/output.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/completion/output/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/descriptor.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/descriptor/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/exception.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/exception/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/formatter.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/formatter/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/helper.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/helper/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/input.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/input/mod.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/output.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/output/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/question.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/question/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/signal_registry.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/signal_registry/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/console/style.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/console/style/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/filesystem.rs create mode 100644 crates/shirabe-external-packages/src/symfony/filesystem/exception.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/filesystem/exception/mod.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/filesystem/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/finder.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/finder/mod.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/process.rs create mode 100644 crates/shirabe-external-packages/src/symfony/process/exception.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/process/exception/mod.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/process/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/process/pipes.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs create mode 100644 crates/shirabe-external-packages/src/symfony/string.rs delete mode 100644 crates/shirabe-external-packages/src/symfony/string/mod.rs (limited to 'crates/shirabe-external-packages') diff --git a/crates/shirabe-external-packages/src/composer.rs b/crates/shirabe-external-packages/src/composer.rs new file mode 100644 index 0000000..907f985 --- /dev/null +++ b/crates/shirabe-external-packages/src/composer.rs @@ -0,0 +1,7 @@ +pub mod ca_bundle; +pub mod pcre; +pub mod xdebug_handler; + +pub use ca_bundle::*; +pub use pcre::*; +pub use xdebug_handler::*; diff --git a/crates/shirabe-external-packages/src/composer/ca_bundle.rs b/crates/shirabe-external-packages/src/composer/ca_bundle.rs new file mode 100644 index 0000000..2a32509 --- /dev/null +++ b/crates/shirabe-external-packages/src/composer/ca_bundle.rs @@ -0,0 +1,3 @@ +pub mod ca_bundle; + +pub use ca_bundle::*; diff --git a/crates/shirabe-external-packages/src/composer/ca_bundle/mod.rs b/crates/shirabe-external-packages/src/composer/ca_bundle/mod.rs deleted file mode 100644 index 2a32509..0000000 --- a/crates/shirabe-external-packages/src/composer/ca_bundle/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod ca_bundle; - -pub use ca_bundle::*; diff --git a/crates/shirabe-external-packages/src/composer/mod.rs b/crates/shirabe-external-packages/src/composer/mod.rs deleted file mode 100644 index 907f985..0000000 --- a/crates/shirabe-external-packages/src/composer/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod ca_bundle; -pub mod pcre; -pub mod xdebug_handler; - -pub use ca_bundle::*; -pub use pcre::*; -pub use xdebug_handler::*; diff --git a/crates/shirabe-external-packages/src/composer/pcre.rs b/crates/shirabe-external-packages/src/composer/pcre.rs new file mode 100644 index 0000000..20c37d0 --- /dev/null +++ b/crates/shirabe-external-packages/src/composer/pcre.rs @@ -0,0 +1,3 @@ +pub mod preg; + +pub use preg::*; diff --git a/crates/shirabe-external-packages/src/composer/pcre/mod.rs b/crates/shirabe-external-packages/src/composer/pcre/mod.rs deleted file mode 100644 index 20c37d0..0000000 --- a/crates/shirabe-external-packages/src/composer/pcre/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod preg; - -pub use preg::*; diff --git a/crates/shirabe-external-packages/src/composer/pcre/preg.rs b/crates/shirabe-external-packages/src/composer/pcre/preg.rs index 2c7430d..b4def4d 100644 --- a/crates/shirabe-external-packages/src/composer/pcre/preg.rs +++ b/crates/shirabe-external-packages/src/composer/pcre/preg.rs @@ -12,12 +12,11 @@ //! See docs/dev/regex-porting.md for more detailed regex porting rules. use indexmap::IndexMap; +pub use shirabe_php_shim::CaptureKey; use shirabe_php_shim::{ PREG_OFFSET_CAPTURE, PREG_SET_ORDER, PREG_SPLIT_OFFSET_CAPTURE, PREG_UNMATCHED_AS_NULL, }; -pub use shirabe_php_shim::CaptureKey; - #[derive(Debug)] pub struct Preg; diff --git a/crates/shirabe-external-packages/src/composer/xdebug_handler.rs b/crates/shirabe-external-packages/src/composer/xdebug_handler.rs new file mode 100644 index 0000000..c95f237 --- /dev/null +++ b/crates/shirabe-external-packages/src/composer/xdebug_handler.rs @@ -0,0 +1,3 @@ +pub mod xdebug_handler; + +pub use xdebug_handler::*; diff --git a/crates/shirabe-external-packages/src/composer/xdebug_handler/mod.rs b/crates/shirabe-external-packages/src/composer/xdebug_handler/mod.rs deleted file mode 100644 index c95f237..0000000 --- a/crates/shirabe-external-packages/src/composer/xdebug_handler/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod xdebug_handler; - -pub use xdebug_handler::*; diff --git a/crates/shirabe-external-packages/src/psr.rs b/crates/shirabe-external-packages/src/psr.rs new file mode 100644 index 0000000..1e6bbb8 --- /dev/null +++ b/crates/shirabe-external-packages/src/psr.rs @@ -0,0 +1,3 @@ +pub mod log; + +pub use log::*; diff --git a/crates/shirabe-external-packages/src/psr/log.rs b/crates/shirabe-external-packages/src/psr/log.rs new file mode 100644 index 0000000..17d71b7 --- /dev/null +++ b/crates/shirabe-external-packages/src/psr/log.rs @@ -0,0 +1,5 @@ +pub mod log_level; +pub mod logger_interface; + +pub use log_level::*; +pub use logger_interface::*; diff --git a/crates/shirabe-external-packages/src/psr/log/mod.rs b/crates/shirabe-external-packages/src/psr/log/mod.rs deleted file mode 100644 index 17d71b7..0000000 --- a/crates/shirabe-external-packages/src/psr/log/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod log_level; -pub mod logger_interface; - -pub use log_level::*; -pub use logger_interface::*; diff --git a/crates/shirabe-external-packages/src/psr/mod.rs b/crates/shirabe-external-packages/src/psr/mod.rs deleted file mode 100644 index 1e6bbb8..0000000 --- a/crates/shirabe-external-packages/src/psr/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod log; - -pub use log::*; diff --git a/crates/shirabe-external-packages/src/seld.rs b/crates/shirabe-external-packages/src/seld.rs new file mode 100644 index 0000000..b7c12c4 --- /dev/null +++ b/crates/shirabe-external-packages/src/seld.rs @@ -0,0 +1,5 @@ +pub mod json_lint; +pub mod signal; + +pub use json_lint::*; +pub use signal::*; diff --git a/crates/shirabe-external-packages/src/seld/json_lint.rs b/crates/shirabe-external-packages/src/seld/json_lint.rs new file mode 100644 index 0000000..8027cb2 --- /dev/null +++ b/crates/shirabe-external-packages/src/seld/json_lint.rs @@ -0,0 +1,9 @@ +pub mod duplicate_key_exception; +pub mod json_parser; +pub mod lexer; +pub mod parsing_exception; + +pub use duplicate_key_exception::*; +pub use json_parser::*; +pub use lexer::*; +pub use parsing_exception::*; diff --git a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs index 7cdf73b..317b4e5 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs @@ -1,13 +1,10 @@ //! ref: composer/vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php -use std::collections::HashMap; - -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use super::DuplicateKeyException; use super::ParsingException; use super::lexer::{Lexer, YylLoc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; /// Semantic value held on the parser value stack ($vstack). Most values are JSON values (PhpMixed), /// but object members are represented as a `[key, value]` pair while being reduced. @@ -42,10 +39,10 @@ enum ActionResult { #[derive(Debug)] pub struct JsonParser { - productions_: HashMap, - terminals_: HashMap, - table: Vec>, - default_actions: HashMap, + productions_: IndexMap, + terminals_: IndexMap, + table: Vec>, + default_actions: IndexMap, } /// Per-parse mutable state. PHP keeps `$flags`/`$stack`/`$vstack`/`$lstack` on the parser instance; @@ -81,7 +78,7 @@ impl JsonParser { pub const ALLOW_DUPLICATE_KEYS_TO_ARRAY: u32 = 16; pub fn new() -> Self { - let productions_: HashMap = [ + let productions_: IndexMap = [ (1, (3, 1)), (2, (5, 1)), (3, (7, 1)), @@ -107,7 +104,7 @@ impl JsonParser { .into_iter() .collect(); - let terminals_: HashMap = [ + let terminals_: IndexMap = [ (2, "error"), (4, "STRING"), (6, "NUMBER"), @@ -127,7 +124,7 @@ impl JsonParser { let table = build_table(); - let default_actions: HashMap = [(16, (2, 6))].into_iter().collect(); + let default_actions: IndexMap = [(16, (2, 6))].into_iter().collect(); Self { productions_, @@ -790,9 +787,9 @@ fn trim_bytes(input: &[u8]) -> Vec { } /// Builds the LALR parse `table`. Indexed by state id (0..=31). -fn build_table() -> Vec> { +fn build_table() -> Vec> { use TableAction::{Action, Goto}; - let mut t: Vec> = (0..32).map(|_| HashMap::new()).collect(); + let mut t: Vec> = (0..32).map(|_| IndexMap::new()).collect(); let mut set = |state: usize, entries: &[(i64, TableAction)]| { for (sym, act) in entries { diff --git a/crates/shirabe-external-packages/src/seld/json_lint/mod.rs b/crates/shirabe-external-packages/src/seld/json_lint/mod.rs deleted file mode 100644 index 8027cb2..0000000 --- a/crates/shirabe-external-packages/src/seld/json_lint/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod duplicate_key_exception; -pub mod json_parser; -pub mod lexer; -pub mod parsing_exception; - -pub use duplicate_key_exception::*; -pub use json_parser::*; -pub use lexer::*; -pub use parsing_exception::*; diff --git a/crates/shirabe-external-packages/src/seld/mod.rs b/crates/shirabe-external-packages/src/seld/mod.rs deleted file mode 100644 index b7c12c4..0000000 --- a/crates/shirabe-external-packages/src/seld/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod json_lint; -pub mod signal; - -pub use json_lint::*; -pub use signal::*; diff --git a/crates/shirabe-external-packages/src/seld/signal.rs b/crates/shirabe-external-packages/src/seld/signal.rs new file mode 100644 index 0000000..16f5151 --- /dev/null +++ b/crates/shirabe-external-packages/src/seld/signal.rs @@ -0,0 +1,3 @@ +pub mod signal_handler; + +pub use signal_handler::*; diff --git a/crates/shirabe-external-packages/src/seld/signal/mod.rs b/crates/shirabe-external-packages/src/seld/signal/mod.rs deleted file mode 100644 index 16f5151..0000000 --- a/crates/shirabe-external-packages/src/seld/signal/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod signal_handler; - -pub use signal_handler::*; diff --git a/crates/shirabe-external-packages/src/symfony.rs b/crates/shirabe-external-packages/src/symfony.rs new file mode 100644 index 0000000..9c572b2 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony.rs @@ -0,0 +1,5 @@ +pub mod console; +pub mod filesystem; +pub mod finder; +pub mod process; +pub mod string; diff --git a/crates/shirabe-external-packages/src/symfony/console.rs b/crates/shirabe-external-packages/src/symfony/console.rs new file mode 100644 index 0000000..986c9ca --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console.rs @@ -0,0 +1,35 @@ +pub mod application; +pub mod attribute; +pub mod color; +pub mod command; +pub mod command_loader; +pub mod completion; +pub mod cursor; +pub mod descriptor; +pub mod exception; +pub mod formatter; +pub mod helper; +pub mod input; +pub mod output; +pub mod question; +pub mod signal_registry; +pub mod style; +pub mod terminal; + +pub use application::*; +pub use attribute::*; +pub use color::*; +pub use command::*; +pub use command_loader::*; +pub use completion::*; +pub use cursor::*; +pub use descriptor::*; +pub use exception::*; +pub use formatter::*; +pub use helper::*; +pub use input::*; +pub use output::*; +pub use question::*; +pub use signal_registry::*; +pub use style::*; +pub use terminal::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/attribute.rs b/crates/shirabe-external-packages/src/symfony/console/attribute.rs new file mode 100644 index 0000000..241eb67 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/attribute.rs @@ -0,0 +1,3 @@ +pub mod as_command; + +pub use as_command::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/attribute/mod.rs b/crates/shirabe-external-packages/src/symfony/console/attribute/mod.rs deleted file mode 100644 index 241eb67..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/attribute/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod as_command; - -pub use as_command::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/command.rs b/crates/shirabe-external-packages/src/symfony/console/command.rs new file mode 100644 index 0000000..b17d7f5 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/command.rs @@ -0,0 +1,13 @@ +pub mod command; +pub mod complete_command; +pub mod dump_completion_command; +pub mod help_command; +pub mod list_command; +pub mod signalable_command_interface; + +pub use command::*; +pub use complete_command::*; +pub use dump_completion_command::*; +pub use help_command::*; +pub use list_command::*; +pub use signalable_command_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs index 3ed968e..7df1f80 100644 --- a/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs +++ b/crates/shirabe-external-packages/src/symfony/console/command/complete_command.rs @@ -1,11 +1,5 @@ //! ref: composer/vendor/symfony/console/Command/CompleteCommand.php -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; -use std::cell::RefCell; -use std::ops::{Deref, DerefMut}; -use std::rc::Rc; - use crate::symfony::console::command::command::{Command, CommandData}; use crate::symfony::console::completion::completion_input::CompletionInput; use crate::symfony::console::completion::completion_suggestions::{ @@ -15,6 +9,11 @@ use crate::symfony::console::completion::output::completion_output_interface::Co use crate::symfony::console::input::input_interface::InputInterface; use crate::symfony::console::input::input_option::InputOption; use crate::symfony::console::output::output_interface::OutputInterface; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; +use std::cell::RefCell; +use std::ops::{Deref, DerefMut}; +use std::rc::Rc; /// Responsible for providing the values to the shell completion. #[derive(Debug)] diff --git a/crates/shirabe-external-packages/src/symfony/console/command/mod.rs b/crates/shirabe-external-packages/src/symfony/console/command/mod.rs deleted file mode 100644 index b17d7f5..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/command/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub mod command; -pub mod complete_command; -pub mod dump_completion_command; -pub mod help_command; -pub mod list_command; -pub mod signalable_command_interface; - -pub use command::*; -pub use complete_command::*; -pub use dump_completion_command::*; -pub use help_command::*; -pub use list_command::*; -pub use signalable_command_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/command_loader.rs b/crates/shirabe-external-packages/src/symfony/console/command_loader.rs new file mode 100644 index 0000000..97b3f54 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/command_loader.rs @@ -0,0 +1,3 @@ +pub mod command_loader_interface; + +pub use command_loader_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/command_loader/mod.rs b/crates/shirabe-external-packages/src/symfony/console/command_loader/mod.rs deleted file mode 100644 index 97b3f54..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/command_loader/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod command_loader_interface; - -pub use command_loader_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/completion.rs b/crates/shirabe-external-packages/src/symfony/console/completion.rs new file mode 100644 index 0000000..cb7f1d1 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/completion.rs @@ -0,0 +1,9 @@ +pub mod completion_input; +pub mod completion_suggestions; +pub mod output; +pub mod suggestion; + +pub use completion_input::*; +pub use completion_suggestions::*; +pub use output::*; +pub use suggestion::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs index fe979cd..e0b8e09 100644 --- a/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs +++ b/crates/shirabe-external-packages/src/symfony/console/completion/completion_input.rs @@ -1,10 +1,9 @@ //! ref: composer/vendor/symfony/console/Completion/CompletionInput.php -use shirabe_php_shim::PhpMixed; - use crate::symfony::console::input::argv_input::ArgvInput; use crate::symfony::console::input::input_definition::InputDefinition; use crate::symfony::console::input::input_option::InputOption; +use shirabe_php_shim::PhpMixed; /// An input specialized for shell completion. /// diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/mod.rs b/crates/shirabe-external-packages/src/symfony/console/completion/mod.rs deleted file mode 100644 index cb7f1d1..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/completion/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod completion_input; -pub mod completion_suggestions; -pub mod output; -pub mod suggestion; - -pub use completion_input::*; -pub use completion_suggestions::*; -pub use output::*; -pub use suggestion::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/output.rs b/crates/shirabe-external-packages/src/symfony/console/completion/output.rs new file mode 100644 index 0000000..6bb0a2e --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/completion/output.rs @@ -0,0 +1,5 @@ +pub mod bash_completion_output; +pub mod completion_output_interface; + +pub use bash_completion_output::*; +pub use completion_output_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/completion/output/mod.rs b/crates/shirabe-external-packages/src/symfony/console/completion/output/mod.rs deleted file mode 100644 index 6bb0a2e..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/completion/output/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod bash_completion_output; -pub mod completion_output_interface; - -pub use bash_completion_output::*; -pub use completion_output_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor.rs new file mode 100644 index 0000000..9f85f92 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/descriptor.rs @@ -0,0 +1,15 @@ +pub mod application_description; +pub mod descriptor; +pub mod descriptor_interface; +pub mod json_descriptor; +pub mod markdown_descriptor; +pub mod text_descriptor; +pub mod xml_descriptor; + +pub use application_description::*; +pub use descriptor::*; +pub use descriptor_interface::*; +pub use json_descriptor::*; +pub use markdown_descriptor::*; +pub use text_descriptor::*; +pub use xml_descriptor::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/mod.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/mod.rs deleted file mode 100644 index 9f85f92..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/descriptor/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -pub mod application_description; -pub mod descriptor; -pub mod descriptor_interface; -pub mod json_descriptor; -pub mod markdown_descriptor; -pub mod text_descriptor; -pub mod xml_descriptor; - -pub use application_description::*; -pub use descriptor::*; -pub use descriptor_interface::*; -pub use json_descriptor::*; -pub use markdown_descriptor::*; -pub use text_descriptor::*; -pub use xml_descriptor::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/exception.rs b/crates/shirabe-external-packages/src/symfony/console/exception.rs new file mode 100644 index 0000000..356b595 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/exception.rs @@ -0,0 +1,17 @@ +pub mod command_not_found_exception; +pub mod exception_interface; +pub mod invalid_argument_exception; +pub mod invalid_option_exception; +pub mod logic_exception; +pub mod missing_input_exception; +pub mod namespace_not_found_exception; +pub mod runtime_exception; + +pub use command_not_found_exception::*; +pub use exception_interface::*; +pub use invalid_argument_exception::*; +pub use invalid_option_exception::*; +pub use logic_exception::*; +pub use missing_input_exception::*; +pub use namespace_not_found_exception::*; +pub use runtime_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs b/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs deleted file mode 100644 index 356b595..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/exception/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -pub mod command_not_found_exception; -pub mod exception_interface; -pub mod invalid_argument_exception; -pub mod invalid_option_exception; -pub mod logic_exception; -pub mod missing_input_exception; -pub mod namespace_not_found_exception; -pub mod runtime_exception; - -pub use command_not_found_exception::*; -pub use exception_interface::*; -pub use invalid_argument_exception::*; -pub use invalid_option_exception::*; -pub use logic_exception::*; -pub use missing_input_exception::*; -pub use namespace_not_found_exception::*; -pub use runtime_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/formatter.rs b/crates/shirabe-external-packages/src/symfony/console/formatter.rs new file mode 100644 index 0000000..716d3fb --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/formatter.rs @@ -0,0 +1,13 @@ +pub mod output_formatter; +pub mod output_formatter_interface; +pub mod output_formatter_style; +pub mod output_formatter_style_interface; +pub mod output_formatter_style_stack; +pub mod wrappable_output_formatter_interface; + +pub use output_formatter::*; +pub use output_formatter_interface::*; +pub use output_formatter_style::*; +pub use output_formatter_style_interface::*; +pub use output_formatter_style_stack::*; +pub use wrappable_output_formatter_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/formatter/mod.rs b/crates/shirabe-external-packages/src/symfony/console/formatter/mod.rs deleted file mode 100644 index 716d3fb..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/formatter/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub mod output_formatter; -pub mod output_formatter_interface; -pub mod output_formatter_style; -pub mod output_formatter_style_interface; -pub mod output_formatter_style_stack; -pub mod wrappable_output_formatter_interface; - -pub use output_formatter::*; -pub use output_formatter_interface::*; -pub use output_formatter_style::*; -pub use output_formatter_style_interface::*; -pub use output_formatter_style_stack::*; -pub use wrappable_output_formatter_interface::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper.rs new file mode 100644 index 0000000..8aed672 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/helper.rs @@ -0,0 +1,33 @@ +pub mod debug_formatter_helper; +pub mod descriptor_helper; +pub mod formatter_helper; +pub mod helper; +pub mod helper_interface; +pub mod helper_set; +pub mod process_helper; +pub mod progress_bar; +pub mod question_helper; +pub mod symfony_question_helper; +pub mod table; +pub mod table_cell; +pub mod table_cell_style; +pub mod table_rows; +pub mod table_separator; +pub mod table_style; + +pub use debug_formatter_helper::*; +pub use descriptor_helper::*; +pub use formatter_helper::*; +pub use helper::*; +pub use helper_interface::*; +pub use helper_set::*; +pub use process_helper::*; +pub use progress_bar::*; +pub use question_helper::*; +pub use symfony_question_helper::*; +pub use table::*; +pub use table_cell::*; +pub use table_cell_style::*; +pub use table_rows::*; +pub use table_separator::*; +pub use table_style::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs index 030fda4..d3731b1 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/debug_formatter_helper.rs @@ -158,7 +158,7 @@ impl DebugFormatterHelper { } fn get_border(&self, id: &str) -> String { - format!(" ", COLORS[self.started[id].border as usize],) + format!(" ", COLORS[self.started[id].border as usize]) } } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs index e1dbd1e..e26915e 100644 --- a/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs +++ b/crates/shirabe-external-packages/src/symfony/console/helper/formatter_helper.rs @@ -16,7 +16,7 @@ pub struct FormatterHelper { impl FormatterHelper { /// Formats a message within a section. pub fn format_section(&self, section: &str, message: &str, style: &str) -> String { - format!("<{}>[{}] {}", style, section, style, message,) + format!("<{}>[{}] {}", style, section, style, message) } /// Formats a message as a block of text. @@ -60,7 +60,7 @@ impl FormatterHelper { let mut i = 0; while i < messages.len() { - messages[i] = format!("<{}>{}", style, messages[i].clone(), style,); + messages[i] = format!("<{}>{}", style, messages[i].clone(), style); i += 1; } diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/mod.rs b/crates/shirabe-external-packages/src/symfony/console/helper/mod.rs deleted file mode 100644 index 8aed672..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/helper/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -pub mod debug_formatter_helper; -pub mod descriptor_helper; -pub mod formatter_helper; -pub mod helper; -pub mod helper_interface; -pub mod helper_set; -pub mod process_helper; -pub mod progress_bar; -pub mod question_helper; -pub mod symfony_question_helper; -pub mod table; -pub mod table_cell; -pub mod table_cell_style; -pub mod table_rows; -pub mod table_separator; -pub mod table_style; - -pub use debug_formatter_helper::*; -pub use descriptor_helper::*; -pub use formatter_helper::*; -pub use helper::*; -pub use helper_interface::*; -pub use helper_set::*; -pub use process_helper::*; -pub use progress_bar::*; -pub use question_helper::*; -pub use symfony_question_helper::*; -pub use table::*; -pub use table_cell::*; -pub use table_cell_style::*; -pub use table_rows::*; -pub use table_separator::*; -pub use table_style::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/input.rs b/crates/shirabe-external-packages/src/symfony/console/input.rs new file mode 100644 index 0000000..d4813b4 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/input.rs @@ -0,0 +1,21 @@ +pub mod argv_input; +pub mod array_input; +pub mod input; +pub mod input_argument; +pub mod input_aware_interface; +pub mod input_definition; +pub mod input_interface; +pub mod input_option; +pub mod streamable_input_interface; +pub mod string_input; + +pub use argv_input::*; +pub use array_input::*; +pub use input::*; +pub use input_argument::*; +pub use input_aware_interface::*; +pub use input_definition::*; +pub use input_interface::*; +pub use input_option::*; +pub use streamable_input_interface::*; +pub use string_input::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs index c1a708a..ad06da7 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/argv_input.rs @@ -317,7 +317,7 @@ impl ArgvInput { let option_name = self.inner.definition.negation_to_name(name)?; if !matches!(value, PhpMixed::Null) { return Err(RuntimeException(shirabe_php_shim::RuntimeException { - message: format!("The \"--{}\" option does not accept a value.", name,), + message: format!("The \"--{}\" option does not accept a value.", name), code: 0, }) .into()); @@ -333,7 +333,7 @@ impl ArgvInput { if !matches!(value, PhpMixed::Null) && !option.accept_value() { return Err(RuntimeException(shirabe_php_shim::RuntimeException { - message: format!("The \"--{}\" option does not accept a value.", name,), + message: format!("The \"--{}\" option does not accept a value.", name), code: 0, }) .into()); diff --git a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs index 051d8bd..eeea48c 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/array_input.rs @@ -259,7 +259,7 @@ impl ArrayInput { if option.is_value_required() { return Err(InvalidOptionException(InvalidArgumentException( shirabe_php_shim::InvalidArgumentException { - message: format!("The \"--{}\" option requires a value.", name,), + message: format!("The \"--{}\" option requires a value.", name), code: 0, }, )) diff --git a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs index a1d3d30..279811f 100644 --- a/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs +++ b/crates/shirabe-external-packages/src/symfony/console/input/input_definition.rs @@ -260,14 +260,14 @@ impl InputDefinition { && !option.equals(existing) { return Err(LogicException(shirabe_php_shim::LogicException { - message: format!("An option named \"{}\" already exists.", option.get_name(),), + message: format!("An option named \"{}\" already exists.", option.get_name()), code: 0, }) .into()); } if self.negations.contains_key(option.get_name()) { return Err(LogicException(shirabe_php_shim::LogicException { - message: format!("An option named \"{}\" already exists.", option.get_name(),), + message: format!("An option named \"{}\" already exists.", option.get_name()), code: 0, }) .into()); diff --git a/crates/shirabe-external-packages/src/symfony/console/input/mod.rs b/crates/shirabe-external-packages/src/symfony/console/input/mod.rs deleted file mode 100644 index d4813b4..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/input/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -pub mod argv_input; -pub mod array_input; -pub mod input; -pub mod input_argument; -pub mod input_aware_interface; -pub mod input_definition; -pub mod input_interface; -pub mod input_option; -pub mod streamable_input_interface; -pub mod string_input; - -pub use argv_input::*; -pub use array_input::*; -pub use input::*; -pub use input_argument::*; -pub use input_aware_interface::*; -pub use input_definition::*; -pub use input_interface::*; -pub use input_option::*; -pub use streamable_input_interface::*; -pub use string_input::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/mod.rs b/crates/shirabe-external-packages/src/symfony/console/mod.rs deleted file mode 100644 index 986c9ca..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/mod.rs +++ /dev/null @@ -1,35 +0,0 @@ -pub mod application; -pub mod attribute; -pub mod color; -pub mod command; -pub mod command_loader; -pub mod completion; -pub mod cursor; -pub mod descriptor; -pub mod exception; -pub mod formatter; -pub mod helper; -pub mod input; -pub mod output; -pub mod question; -pub mod signal_registry; -pub mod style; -pub mod terminal; - -pub use application::*; -pub use attribute::*; -pub use color::*; -pub use command::*; -pub use command_loader::*; -pub use completion::*; -pub use cursor::*; -pub use descriptor::*; -pub use exception::*; -pub use formatter::*; -pub use helper::*; -pub use input::*; -pub use output::*; -pub use question::*; -pub use signal_registry::*; -pub use style::*; -pub use terminal::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/output.rs b/crates/shirabe-external-packages/src/symfony/console/output.rs new file mode 100644 index 0000000..23a8e15 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/output.rs @@ -0,0 +1,17 @@ +pub mod buffered_output; +pub mod console_output; +pub mod console_output_interface; +pub mod console_section_output; +pub mod output; +pub mod output_interface; +pub mod stream_output; +pub mod trimmed_buffer_output; + +pub use buffered_output::*; +pub use console_output::*; +pub use console_output_interface::*; +pub use console_section_output::*; +pub use output::*; +pub use output_interface::*; +pub use stream_output::*; +pub use trimmed_buffer_output::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/output/mod.rs b/crates/shirabe-external-packages/src/symfony/console/output/mod.rs deleted file mode 100644 index 23a8e15..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/output/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -pub mod buffered_output; -pub mod console_output; -pub mod console_output_interface; -pub mod console_section_output; -pub mod output; -pub mod output_interface; -pub mod stream_output; -pub mod trimmed_buffer_output; - -pub use buffered_output::*; -pub use console_output::*; -pub use console_output_interface::*; -pub use console_section_output::*; -pub use output::*; -pub use output_interface::*; -pub use stream_output::*; -pub use trimmed_buffer_output::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/question.rs b/crates/shirabe-external-packages/src/symfony/console/question.rs new file mode 100644 index 0000000..06d03b4 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/question.rs @@ -0,0 +1,7 @@ +mod choice_question; +mod confirmation_question; +mod question; + +pub use choice_question::*; +pub use confirmation_question::*; +pub use question::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/question/mod.rs b/crates/shirabe-external-packages/src/symfony/console/question/mod.rs deleted file mode 100644 index 06d03b4..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/question/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod choice_question; -mod confirmation_question; -mod question; - -pub use choice_question::*; -pub use confirmation_question::*; -pub use question::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/signal_registry.rs b/crates/shirabe-external-packages/src/symfony/console/signal_registry.rs new file mode 100644 index 0000000..a07ca01 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/signal_registry.rs @@ -0,0 +1,3 @@ +pub mod signal_registry; + +pub use signal_registry::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/signal_registry/mod.rs b/crates/shirabe-external-packages/src/symfony/console/signal_registry/mod.rs deleted file mode 100644 index a07ca01..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/signal_registry/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod signal_registry; - -pub use signal_registry::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/style.rs b/crates/shirabe-external-packages/src/symfony/console/style.rs new file mode 100644 index 0000000..efc54e1 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/console/style.rs @@ -0,0 +1,7 @@ +pub mod output_style; +pub mod style_interface; +pub mod symfony_style; + +pub use output_style::*; +pub use style_interface::*; +pub use symfony_style::*; diff --git a/crates/shirabe-external-packages/src/symfony/console/style/mod.rs b/crates/shirabe-external-packages/src/symfony/console/style/mod.rs deleted file mode 100644 index efc54e1..0000000 --- a/crates/shirabe-external-packages/src/symfony/console/style/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod output_style; -pub mod style_interface; -pub mod symfony_style; - -pub use output_style::*; -pub use style_interface::*; -pub use symfony_style::*; diff --git a/crates/shirabe-external-packages/src/symfony/filesystem.rs b/crates/shirabe-external-packages/src/symfony/filesystem.rs new file mode 100644 index 0000000..24be2ed --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/filesystem.rs @@ -0,0 +1,5 @@ +pub mod exception; +pub mod filesystem; + +pub use exception::*; +pub use filesystem::*; diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/exception.rs b/crates/shirabe-external-packages/src/symfony/filesystem/exception.rs new file mode 100644 index 0000000..2c19405 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/filesystem/exception.rs @@ -0,0 +1,3 @@ +pub mod io_exception; + +pub use io_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/exception/mod.rs b/crates/shirabe-external-packages/src/symfony/filesystem/exception/mod.rs deleted file mode 100644 index 2c19405..0000000 --- a/crates/shirabe-external-packages/src/symfony/filesystem/exception/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod io_exception; - -pub use io_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/filesystem/mod.rs b/crates/shirabe-external-packages/src/symfony/filesystem/mod.rs deleted file mode 100644 index 24be2ed..0000000 --- a/crates/shirabe-external-packages/src/symfony/filesystem/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod exception; -pub mod filesystem; - -pub use exception::*; -pub use filesystem::*; diff --git a/crates/shirabe-external-packages/src/symfony/finder.rs b/crates/shirabe-external-packages/src/symfony/finder.rs new file mode 100644 index 0000000..4b2d4b8 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/finder.rs @@ -0,0 +1,7 @@ +pub mod finder; +pub mod glob; +pub mod spl_file_info; + +pub use finder::*; +pub use glob::*; +pub use spl_file_info::*; diff --git a/crates/shirabe-external-packages/src/symfony/finder/finder.rs b/crates/shirabe-external-packages/src/symfony/finder/finder.rs index 95ca5a4..2a7e544 100644 --- a/crates/shirabe-external-packages/src/symfony/finder/finder.rs +++ b/crates/shirabe-external-packages/src/symfony/finder/finder.rs @@ -9,10 +9,9 @@ use crate::composer::pcre::{CaptureKey, Preg}; use crate::symfony::finder::glob::Glob; use chrono::{NaiveDate, NaiveDateTime}; -use indexmap::IndexMap; +use indexmap::{IndexMap, IndexSet}; use shirabe_php_shim::{file_exists, glob, is_dir, preg_quote, rtrim}; use std::cell::RefCell; -use std::collections::HashSet; use std::path::{Path, PathBuf}; use std::time::UNIX_EPOCH; @@ -448,7 +447,7 @@ impl Finder { relative_dir: &str, depth: i64, max_depth: i64, - excluded_dirs: &HashSet, + excluded_dirs: &IndexSet, excluded_pattern: &Option, out: &mut Vec, ) { @@ -553,8 +552,8 @@ impl Finder { /// Reproduces `ExcludeDirectoryFilterIterator`'s constructor split between simple /// directory names and `/`-containing path patterns. -fn build_exclude(directories: &[String]) -> (HashSet, Option) { - let mut excluded_dirs = HashSet::new(); +fn build_exclude(directories: &[String]) -> (IndexSet, Option) { + let mut excluded_dirs = IndexSet::new(); let mut patterns: Vec = Vec::new(); for directory in directories { @@ -579,7 +578,7 @@ fn build_exclude(directories: &[String]) -> (HashSet, Option) { /// `ExcludeDirectoryFilterIterator::accept`. fn exclude_accept( entry: &Entry, - excluded_dirs: &HashSet, + excluded_dirs: &IndexSet, excluded_pattern: &Option, ) -> bool { if excluded_dirs.contains(&entry.filename) && entry.is_dir { diff --git a/crates/shirabe-external-packages/src/symfony/finder/mod.rs b/crates/shirabe-external-packages/src/symfony/finder/mod.rs deleted file mode 100644 index 4b2d4b8..0000000 --- a/crates/shirabe-external-packages/src/symfony/finder/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub mod finder; -pub mod glob; -pub mod spl_file_info; - -pub use finder::*; -pub use glob::*; -pub use spl_file_info::*; diff --git a/crates/shirabe-external-packages/src/symfony/mod.rs b/crates/shirabe-external-packages/src/symfony/mod.rs deleted file mode 100644 index 9c572b2..0000000 --- a/crates/shirabe-external-packages/src/symfony/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod console; -pub mod filesystem; -pub mod finder; -pub mod process; -pub mod string; diff --git a/crates/shirabe-external-packages/src/symfony/process.rs b/crates/shirabe-external-packages/src/symfony/process.rs new file mode 100644 index 0000000..15967be --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/process.rs @@ -0,0 +1,13 @@ +pub mod exception; +pub mod executable_finder; +pub mod php_executable_finder; +pub mod pipes; +pub mod process; +pub mod process_utils; + +pub use exception::*; +pub use executable_finder::*; +pub use php_executable_finder::*; +pub use pipes::*; +pub use process::*; +pub use process_utils::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/exception.rs b/crates/shirabe-external-packages/src/symfony/process/exception.rs new file mode 100644 index 0000000..689a64b --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/process/exception.rs @@ -0,0 +1,13 @@ +pub mod invalid_argument_exception; +pub mod logic_exception; +pub mod process_failed_exception; +pub mod process_signaled_exception; +pub mod process_timed_out_exception; +pub mod runtime_exception; + +pub use invalid_argument_exception::*; +pub use logic_exception::*; +pub use process_failed_exception::*; +pub use process_signaled_exception::*; +pub use process_timed_out_exception::*; +pub use runtime_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/exception/mod.rs b/crates/shirabe-external-packages/src/symfony/process/exception/mod.rs deleted file mode 100644 index 689a64b..0000000 --- a/crates/shirabe-external-packages/src/symfony/process/exception/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub mod invalid_argument_exception; -pub mod logic_exception; -pub mod process_failed_exception; -pub mod process_signaled_exception; -pub mod process_timed_out_exception; -pub mod runtime_exception; - -pub use invalid_argument_exception::*; -pub use logic_exception::*; -pub use process_failed_exception::*; -pub use process_signaled_exception::*; -pub use process_timed_out_exception::*; -pub use runtime_exception::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs index a151283..3396b29 100644 --- a/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs +++ b/crates/shirabe-external-packages/src/symfony/process/executable_finder.rs @@ -1,6 +1,6 @@ //! ref: composer/vendor/symfony/process/ExecutableFinder.php -use shirabe_php_shim::{self as php, PhpMixed}; +use shirabe_php_shim::PhpMixed; const CMD_BUILTINS: &[&str] = &[ "assoc", "break", "call", "cd", "chdir", "cls", "color", "copy", "date", "del", "dir", "echo", @@ -37,25 +37,28 @@ impl ExecutableFinder { pub fn find(&self, name: &str, default: Option<&str>, extra_dirs: &[String]) -> Option { // windows built-in commands that are present in cmd.exe should not be resolved using PATH as they do not exist as exes - if php::DIRECTORY_SEPARATOR == "\\" - && CMD_BUILTINS.contains(&php::strtolower(name).as_str()) + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + && CMD_BUILTINS.contains(&shirabe_php_shim::strtolower(name).as_str()) { return Some(name.to_string()); } - let path = php::getenv("PATH") - .or_else(|| php::getenv("Path")) + let path = shirabe_php_shim::getenv("PATH") + .or_else(|| shirabe_php_shim::getenv("Path")) .map(|v| v.to_string_lossy().into_owned()) .unwrap_or_default(); - let mut dirs = php::explode(php::PATH_SEPARATOR, &path); + let mut dirs = shirabe_php_shim::explode(shirabe_php_shim::PATH_SEPARATOR, &path); dirs.extend_from_slice(extra_dirs); let mut suffixes: Vec = vec![]; - if php::DIRECTORY_SEPARATOR == "\\" { - let path_ext = php::getenv("PATHEXT").map(|v| v.to_string_lossy().into_owned()); + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { + let path_ext = + shirabe_php_shim::getenv("PATHEXT").map(|v| v.to_string_lossy().into_owned()); suffixes = self.suffixes.clone(); let exts = match path_ext { - Some(ref ext) if !ext.is_empty() => php::explode(php::PATH_SEPARATOR, ext), + Some(ref ext) if !ext.is_empty() => { + shirabe_php_shim::explode(shirabe_php_shim::PATH_SEPARATOR, ext) + } _ => vec![ ".exe".to_string(), ".bat".to_string(), @@ -65,10 +68,13 @@ impl ExecutableFinder { }; suffixes.extend(exts); } - suffixes = if !php::pathinfo(PhpMixed::String(name.to_string()), php::PATHINFO_EXTENSION) - .as_string() - .unwrap_or("") - .is_empty() + suffixes = if !shirabe_php_shim::pathinfo( + PhpMixed::String(name.to_string()), + shirabe_php_shim::PATHINFO_EXTENSION, + ) + .as_string() + .unwrap_or("") + .is_empty() { let mut s = vec![String::new()]; s.extend(suffixes); @@ -80,41 +86,49 @@ impl ExecutableFinder { for suffix in &suffixes { for dir in &dirs { let dir = if dir.is_empty() { "." } else { dir.as_str() }; - let file = format!("{dir}{}{name}{suffix}", php::DIRECTORY_SEPARATOR); - if php::is_file(&file) - && (php::DIRECTORY_SEPARATOR == "\\" || php::is_executable(&file)) + let file = format!( + "{dir}{}{name}{suffix}", + shirabe_php_shim::DIRECTORY_SEPARATOR + ); + if shirabe_php_shim::is_file(&file) + && (shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + || shirabe_php_shim::is_executable(&file)) { return Some(file); } - if !php::is_dir(dir) - && php::basename(dir) == format!("{name}{suffix}") - && php::is_executable(dir) + if !shirabe_php_shim::is_dir(dir) + && shirabe_php_shim::basename(dir) == format!("{name}{suffix}") + && shirabe_php_shim::is_executable(dir) { return Some(dir.to_string()); } } } - if php::DIRECTORY_SEPARATOR == "\\" - || name.len() != php::strcspn(name, &format!("/{}", php::DIRECTORY_SEPARATOR)) + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" + || name.len() + != shirabe_php_shim::strcspn( + name, + &format!("/{}", shirabe_php_shim::DIRECTORY_SEPARATOR), + ) { return default.map(ToString::to_string); } - let exec_result = php::exec( - &format!("command -v -- {}", php::escapeshellarg(name)), + let exec_result = shirabe_php_shim::exec( + &format!("command -v -- {}", shirabe_php_shim::escapeshellarg(name)), None, None, ) .unwrap_or_default(); - let executable_path = php::substr( + let executable_path = shirabe_php_shim::substr( &exec_result, 0, - php::strpos(&exec_result, php::PHP_EOL).map(|i| i as i64), + shirabe_php_shim::strpos(&exec_result, shirabe_php_shim::PHP_EOL).map(|i| i as i64), ); - if !executable_path.is_empty() && php::is_executable(&executable_path) { + if !executable_path.is_empty() && shirabe_php_shim::is_executable(&executable_path) { return Some(executable_path); } diff --git a/crates/shirabe-external-packages/src/symfony/process/mod.rs b/crates/shirabe-external-packages/src/symfony/process/mod.rs deleted file mode 100644 index 15967be..0000000 --- a/crates/shirabe-external-packages/src/symfony/process/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub mod exception; -pub mod executable_finder; -pub mod php_executable_finder; -pub mod pipes; -pub mod process; -pub mod process_utils; - -pub use exception::*; -pub use executable_finder::*; -pub use php_executable_finder::*; -pub use pipes::*; -pub use process::*; -pub use process_utils::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/php_executable_finder.rs b/crates/shirabe-external-packages/src/symfony/process/php_executable_finder.rs index 9d04c5e..55ace18 100644 --- a/crates/shirabe-external-packages/src/symfony/process/php_executable_finder.rs +++ b/crates/shirabe-external-packages/src/symfony/process/php_executable_finder.rs @@ -1,7 +1,6 @@ //! ref: composer/vendor/symfony/process/PhpExecutableFinder.php use super::executable_finder::ExecutableFinder; -use shirabe_php_shim::{self as php}; #[derive(Debug)] pub struct PhpExecutableFinder { @@ -23,16 +22,16 @@ impl PhpExecutableFinder { /// Finds The PHP executable. pub fn find(&self, include_args: bool) -> Option { - if let Some(php) = php::getenv("PHP_BINARY").filter(|v| !v.is_empty()) { + if let Some(php) = shirabe_php_shim::getenv("PHP_BINARY").filter(|v| !v.is_empty()) { let mut php = php.to_string_lossy().into_owned(); - if !php::is_executable(&php) { + if !shirabe_php_shim::is_executable(&php) { match self.executable_finder.find(&php, None, &[]) { Some(found) => php = found, None => return None, } } - if php::is_dir(&php) { + if shirabe_php_shim::is_dir(&php) { return None; } diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes.rs new file mode 100644 index 0000000..6a77f5f --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/process/pipes.rs @@ -0,0 +1,9 @@ +pub mod abstract_pipes; +pub mod pipes_interface; +pub mod unix_pipes; +pub mod windows_pipes; + +pub use abstract_pipes::*; +pub use pipes_interface::*; +pub use unix_pipes::*; +pub use windows_pipes::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs index 43a6567..f9fb251 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/abstract_pipes.rs @@ -1,7 +1,7 @@ //! ref: composer/vendor/symfony/process/Pipes/AbstractPipes.php use indexmap::IndexMap; -use shirabe_php_shim::{self as php, PhpMixed, PhpResource}; +use shirabe_php_shim::{PhpMixed, PhpResource}; #[derive(Debug)] pub struct AbstractPipes { @@ -38,7 +38,7 @@ impl AbstractPipes { pub fn close(&mut self) { for (_, pipe) in &self.pipes { - php::fclose(pipe); + shirabe_php_shim::fclose(pipe); } self.pipes = IndexMap::new(); } @@ -60,7 +60,7 @@ impl AbstractPipes { } for (_, pipe) in &self.pipes { - php::stream_set_blocking(pipe, false); + shirabe_php_shim::stream_set_blocking(pipe, false); } // The `is_resource($this->input)` branch does not apply: `input` is never a resource in this // port (is_resource on a PhpMixed is always false). @@ -81,10 +81,11 @@ impl AbstractPipes { let mut w: Vec = vec![stdin.clone()]; // let's have a look if something changed in streams - php::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?; + shirabe_php_shim::stream_select(&mut r, &mut w, &mut e, 0, Some(0))?; if !self.input_buffer.is_empty() { - let written = php::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize; + let written = + shirabe_php_shim::fwrite(&stdin, &self.input_buffer, None).unwrap_or(0) as usize; self.input_buffer = self.input_buffer.get(written..).unwrap_or("").to_string(); if !self.input_buffer.is_empty() { return Some(vec![stdin]); @@ -92,9 +93,9 @@ impl AbstractPipes { } // no input to read on resource, buffer is empty - if self.input_buffer.is_empty() && !php::php_truthy(&self.input) { + if self.input_buffer.is_empty() && !shirabe_php_shim::php_truthy(&self.input) { self.input = PhpMixed::Null; - php::fclose(&stdin); + shirabe_php_shim::fclose(&stdin); self.pipes.shift_remove(&0); } diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs deleted file mode 100644 index 6a77f5f..0000000 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod abstract_pipes; -pub mod pipes_interface; -pub mod unix_pipes; -pub mod windows_pipes; - -pub use abstract_pipes::*; -pub use pipes_interface::*; -pub use unix_pipes::*; -pub use windows_pipes::*; diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs index 795bb64..aff2a54 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/unix_pipes.rs @@ -1,11 +1,10 @@ //! ref: composer/vendor/symfony/process/Pipes/UnixPipes.php -use indexmap::IndexMap; -use shirabe_php_shim::{self as php, Descriptor, PhpMixed, PhpResource}; - use crate::symfony::process::pipes::abstract_pipes::AbstractPipes; use crate::symfony::process::pipes::pipes_interface::{CHUNK_SIZE, PipesInterface}; use crate::symfony::process::process::Process; +use indexmap::IndexMap; +use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource}; /// UnixPipes implementation uses unix pipes as handles. #[derive(Debug)] @@ -44,7 +43,8 @@ fn descriptor(items: &[&str]) -> Descriptor { impl PipesInterface for UnixPipes { fn get_descriptors(&mut self) -> Vec { if !self.have_read_support { - let nullstream = php::fopen("/dev/null", "c").expect("fopen('/dev/null') failed"); + let nullstream = + shirabe_php_shim::fopen("/dev/null", "c").expect("fopen('/dev/null') failed"); return vec![ descriptor(&["pipe", "r"]), Descriptor::Resource(nullstream.clone()), @@ -100,7 +100,7 @@ impl PipesInterface for UnixPipes { // let's have a look if something changed in streams if (!r_sel.is_empty() || w.is_some()) - && php::stream_select( + && shirabe_php_shim::stream_select( &mut r_sel, &mut w_sel, &mut e_sel, @@ -125,7 +125,7 @@ impl PipesInterface for UnixPipes { for (fd, pipe) in &r { let mut data = String::new(); loop { - let chunk = php::fread(pipe, CHUNK_SIZE).unwrap_or_default(); + let chunk = shirabe_php_shim::fread(pipe, CHUNK_SIZE).unwrap_or_default(); let len = chunk.len() as i64; data.push_str(&chunk); if !(len > 0 && (close || len >= CHUNK_SIZE)) { @@ -137,8 +137,8 @@ impl PipesInterface for UnixPipes { read.insert(*fd, data); } - if close && php::feof(pipe) { - php::fclose(pipe); + if close && shirabe_php_shim::feof(pipe) { + shirabe_php_shim::fclose(pipe); self.inner.pipes.shift_remove(fd); } } diff --git a/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs b/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs index a31f184..f721d2b 100644 --- a/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs +++ b/crates/shirabe-external-packages/src/symfony/process/pipes/windows_pipes.rs @@ -1,10 +1,9 @@ //! ref: composer/vendor/symfony/process/Pipes/WindowsPipes.php -use indexmap::IndexMap; -use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource}; - use crate::symfony::process::pipes::abstract_pipes::AbstractPipes; use crate::symfony::process::pipes::pipes_interface::PipesInterface; +use indexmap::IndexMap; +use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource}; /// WindowsPipes implementation uses temporary files as handles. #[derive(Debug)] diff --git a/crates/shirabe-external-packages/src/symfony/process/process.rs b/crates/shirabe-external-packages/src/symfony/process/process.rs index fbf2da7..84bed62 100644 --- a/crates/shirabe-external-packages/src/symfony/process/process.rs +++ b/crates/shirabe-external-packages/src/symfony/process/process.rs @@ -1,10 +1,5 @@ //! ref: composer/vendor/symfony/process/Process.php -use std::sync::OnceLock; - -use indexmap::IndexMap; -use shirabe_php_shim::{self as php, Descriptor, PhpMixed, PhpResource}; - use crate::symfony::process::exception::invalid_argument_exception::InvalidArgumentException; use crate::symfony::process::exception::logic_exception::LogicException; use crate::symfony::process::exception::process_failed_exception::ProcessFailedException; @@ -16,6 +11,9 @@ use crate::symfony::process::pipes::pipes_interface::PipesInterface; use crate::symfony::process::pipes::unix_pipes::UnixPipes; use crate::symfony::process::pipes::windows_pipes::WindowsPipes; use crate::symfony::process::process_utils::ProcessUtils; +use indexmap::IndexMap; +use shirabe_php_shim::{Descriptor, PhpMixed, PhpResource}; +use std::sync::OnceLock; /// A user-supplied callback invoked with the output type ("out"/"err") and a chunk of output. pub type UserCallback = Box bool>; @@ -210,7 +208,7 @@ impl Process { input: PhpMixed, timeout: Option, ) -> anyhow::Result { - if !php::function_exists("proc_open") { + if !shirabe_php_shim::function_exists("proc_open") { return Err(LogicException::new( "The Process class relies on proc_open, which is not available on your PHP installation.".to_string(), ) @@ -227,7 +225,7 @@ impl Process { // exists; its value merely reflects the NTS/ZTS build), so the disjunction is always true and // the cwd is defaulted to getcwd() whenever it was null. if this.cwd.is_none() { - this.cwd = php::getcwd(); + this.cwd = shirabe_php_shim::getcwd(); } if let Some(env) = env { this.set_env( @@ -239,7 +237,7 @@ impl Process { this.set_input(input)?; this.set_timeout(timeout)?; - this.use_file_handles = php::DIRECTORY_SEPARATOR == "\\"; + this.use_file_handles = shirabe_php_shim::DIRECTORY_SEPARATOR == "\\"; this.pty = false; Ok(this) @@ -260,7 +258,7 @@ impl Process { } pub fn __sleep(&self) -> anyhow::Result> { - Err(php::BadMethodCallException { + Err(shirabe_php_shim::BadMethodCallException { message: "Cannot serialize Symfony\\Component\\Process\\Process".to_string(), code: 0, } @@ -268,7 +266,7 @@ impl Process { } pub fn __wakeup(&self) -> anyhow::Result<()> { - Err(php::BadMethodCallException { + Err(shirabe_php_shim::BadMethodCallException { message: "Cannot unserialize Symfony\\Component\\Process\\Process".to_string(), code: 0, } @@ -310,7 +308,7 @@ impl Process { } self.reset_process_data(); - self.starttime = Some(php::microtime()); + self.starttime = Some(shirabe_php_shim::microtime()); self.last_output_time = self.starttime; let has_callback = callback.is_some(); self.callback = Some(self.build_callback(callback)); @@ -336,7 +334,7 @@ impl Process { .collect::>() .join(" "); - if php::DIRECTORY_SEPARATOR != "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" { // exec is mandatory to deal with sending a signal to the process cmd = format!("exec {}", cmd); } @@ -345,7 +343,7 @@ impl Process { CommandLine::String(s) => self.replace_placeholders(s, &env)?, }; - if php::DIRECTORY_SEPARATOR == "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { commandline = self.prepare_windows_command_line(&commandline, &mut env)?; } else if !self.use_file_handles && self.is_sigchild_enabled() { // last exit code is output on the fourth pipe and caught to work around --enable-sigchild @@ -357,7 +355,7 @@ impl Process { ); // Workaround for the bug, when PTS functionality is enabled. - let _pts_workaround = php::fopen("Process.php", "r"); + let _pts_workaround = shirabe_php_shim::fopen("Process.php", "r"); } let mut env_pairs: Vec = Vec::new(); @@ -368,7 +366,12 @@ impl Process { } } - if !self.cwd.as_deref().map(php::is_dir).unwrap_or(false) { + if !self + .cwd + .as_deref() + .map(shirabe_php_shim::is_dir) + .unwrap_or(false) + { return Err(RuntimeException::new(format!( "The provided cwd \"{}\" does not exist.", self.cwd.as_deref().unwrap_or("") @@ -380,7 +383,7 @@ impl Process { let options = self.options.clone(); let process = { let pipes = self.process_pipes.as_mut().unwrap().pipes_mut(); - php::proc_open( + shirabe_php_shim::proc_open( &commandline, &descriptors, pipes, @@ -407,7 +410,7 @@ impl Process { .get(&3) .cloned(); let pid = pipe3 - .and_then(|p| php::fgets(&p, None)) + .and_then(|p| shirabe_php_shim::fgets(&p, None)) .map(|s| s.trim().parse::().unwrap_or(0)) .unwrap_or(0); self.fallback_status @@ -459,9 +462,12 @@ impl Process { loop { self.check_timeout()?; let running = self.is_running() - && (php::DIRECTORY_SEPARATOR == "\\" + && (shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" || self.process_pipes.as_ref().unwrap().are_open()); - self.read_pipes(running, php::DIRECTORY_SEPARATOR != "\\" || !running); + self.read_pipes( + running, + shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" || !running, + ); if !running { break; } @@ -469,14 +475,14 @@ impl Process { while self.is_running() { self.check_timeout()?; - php::usleep(1000); + shirabe_php_shim::usleep(1000); } let signaled = self .process_information .as_ref() .and_then(|i| i.get("signaled")) - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false); let termsig = self .process_information @@ -507,16 +513,15 @@ impl Process { let mut ready = false; loop { self.check_timeout()?; - let running = if php::DIRECTORY_SEPARATOR == "\\" { + let running = if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { self.is_running() } else { self.process_pipes.as_ref().unwrap().are_open() }; - let output = self - .process_pipes - .as_mut() - .unwrap() - .read_and_write(running, php::DIRECTORY_SEPARATOR != "\\" || !running); + let output = self.process_pipes.as_mut().unwrap().read_and_write( + running, + shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" || !running, + ); for (r#type, data) in output { if r#type != 3 { @@ -544,7 +549,7 @@ impl Process { return Ok(false); } - php::usleep(1000); + shirabe_php_shim::usleep(1000); } } @@ -609,19 +614,23 @@ impl Process { pub fn get_output(&mut self) -> anyhow::Result { self.read_pipes_for_output("getOutput", false)?; - Ok(php::stream_get_contents3(self.stdout.as_ref().unwrap(), -1, 0).unwrap_or_default()) + Ok( + shirabe_php_shim::stream_get_contents3(self.stdout.as_ref().unwrap(), -1, 0) + .unwrap_or_default(), + ) } /// Returns the output incrementally. pub fn get_incremental_output(&mut self) -> anyhow::Result { self.read_pipes_for_output("getIncrementalOutput", false)?; - let latest = php::stream_get_contents3( + let latest = shirabe_php_shim::stream_get_contents3( self.stdout.as_ref().unwrap(), -1, self.incremental_output_offset, ); - self.incremental_output_offset = php::ftell(self.stdout.as_ref().unwrap()).unwrap_or(0); + self.incremental_output_offset = + shirabe_php_shim::ftell(self.stdout.as_ref().unwrap()).unwrap_or(0); Ok(latest.unwrap_or_default()) } @@ -639,14 +648,14 @@ impl Process { let mut yields = Vec::new(); while self.callback.is_some() - || (yield_out && !php::feof(self.stdout.as_ref().unwrap())) - || (yield_err && !php::feof(self.stderr.as_ref().unwrap())) + || (yield_out && !shirabe_php_shim::feof(self.stdout.as_ref().unwrap())) + || (yield_err && !shirabe_php_shim::feof(self.stderr.as_ref().unwrap())) { let mut got_out = false; let mut got_err = false; if yield_out { - let out = php::stream_get_contents3( + let out = shirabe_php_shim::stream_get_contents3( self.stdout.as_ref().unwrap(), -1, self.incremental_output_offset, @@ -659,7 +668,7 @@ impl Process { self.clear_output(); } else { self.incremental_output_offset = - php::ftell(self.stdout.as_ref().unwrap()).unwrap_or(0); + shirabe_php_shim::ftell(self.stdout.as_ref().unwrap()).unwrap_or(0); } yields.push((Self::OUT.to_string(), out)); @@ -667,7 +676,7 @@ impl Process { } if yield_err { - let err = php::stream_get_contents3( + let err = shirabe_php_shim::stream_get_contents3( self.stderr.as_ref().unwrap(), -1, self.incremental_error_output_offset, @@ -680,7 +689,7 @@ impl Process { self.clear_error_output(); } else { self.incremental_error_output_offset = - php::ftell(self.stderr.as_ref().unwrap()).unwrap_or(0); + shirabe_php_shim::ftell(self.stderr.as_ref().unwrap()).unwrap_or(0); } yields.push((Self::ERR.to_string(), err)); @@ -700,8 +709,8 @@ impl Process { /// Clears the process output. pub fn clear_output(&mut self) -> &mut Self { - php::ftruncate(self.stdout.as_ref().unwrap(), 0); - php::fseek(self.stdout.as_ref().unwrap(), 0, php::SEEK_SET); + shirabe_php_shim::ftruncate(self.stdout.as_ref().unwrap(), 0); + shirabe_php_shim::fseek(self.stdout.as_ref().unwrap(), 0, shirabe_php_shim::SEEK_SET); self.incremental_output_offset = 0; self @@ -711,28 +720,31 @@ impl Process { pub fn get_error_output(&mut self) -> anyhow::Result { self.read_pipes_for_output("getErrorOutput", false)?; - Ok(php::stream_get_contents3(self.stderr.as_ref().unwrap(), -1, 0).unwrap_or_default()) + Ok( + shirabe_php_shim::stream_get_contents3(self.stderr.as_ref().unwrap(), -1, 0) + .unwrap_or_default(), + ) } /// Returns the errorOutput incrementally. pub fn get_incremental_error_output(&mut self) -> anyhow::Result { self.read_pipes_for_output("getIncrementalErrorOutput", false)?; - let latest = php::stream_get_contents3( + let latest = shirabe_php_shim::stream_get_contents3( self.stderr.as_ref().unwrap(), -1, self.incremental_error_output_offset, ); self.incremental_error_output_offset = - php::ftell(self.stderr.as_ref().unwrap()).unwrap_or(0); + shirabe_php_shim::ftell(self.stderr.as_ref().unwrap()).unwrap_or(0); Ok(latest.unwrap_or_default()) } /// Clears the process error output. pub fn clear_error_output(&mut self) -> &mut Self { - php::ftruncate(self.stderr.as_ref().unwrap(), 0); - php::fseek(self.stderr.as_ref().unwrap(), 0, php::SEEK_SET); + shirabe_php_shim::ftruncate(self.stderr.as_ref().unwrap(), 0); + shirabe_php_shim::fseek(self.stderr.as_ref().unwrap(), 0, shirabe_php_shim::SEEK_SET); self.incremental_error_output_offset = 0; self @@ -769,7 +781,7 @@ impl Process { .process_information .as_ref() .and_then(|i| i.get("signaled")) - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false)) } @@ -800,7 +812,7 @@ impl Process { .process_information .as_ref() .and_then(|i| i.get("stopped")) - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false)) } @@ -827,7 +839,7 @@ impl Process { self.process_information .as_ref() .and_then(|i| i.get("running")) - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false) } @@ -852,14 +864,14 @@ impl Process { /// Stops the process. pub fn stop(&mut self, timeout: f64, signal: Option) -> Option { - let timeout_micro = php::microtime() + timeout; + let timeout_micro = shirabe_php_shim::microtime() + timeout; if self.is_running() { // given SIGTERM may not be defined and that "proc_terminate" uses the constant value // and not the constant itself, we use the same here let _ = self.do_signal(15, false); loop { - php::usleep(1000); - if !(self.is_running() && php::microtime() < timeout_micro) { + shirabe_php_shim::usleep(1000); + if !(self.is_running() && shirabe_php_shim::microtime() < timeout_micro) { break; } } @@ -885,22 +897,30 @@ impl Process { /// Adds a line to the STDOUT stream. pub fn add_output(&mut self, line: &str) { - self.last_output_time = Some(php::microtime()); + self.last_output_time = Some(shirabe_php_shim::microtime()); let stdout = self.stdout.as_ref().unwrap(); - php::fseek(stdout, 0, php::SEEK_END); - php::fwrite(stdout, line, Some(line.len() as i64)); - php::fseek(stdout, self.incremental_output_offset, php::SEEK_SET); + shirabe_php_shim::fseek(stdout, 0, shirabe_php_shim::SEEK_END); + shirabe_php_shim::fwrite(stdout, line, Some(line.len() as i64)); + shirabe_php_shim::fseek( + stdout, + self.incremental_output_offset, + shirabe_php_shim::SEEK_SET, + ); } /// Adds a line to the STDERR stream. pub fn add_error_output(&mut self, line: &str) { - self.last_output_time = Some(php::microtime()); + self.last_output_time = Some(shirabe_php_shim::microtime()); let stderr = self.stderr.as_ref().unwrap(); - php::fseek(stderr, 0, php::SEEK_END); - php::fwrite(stderr, line, Some(line.len() as i64)); - php::fseek(stderr, self.incremental_error_output_offset, php::SEEK_SET); + shirabe_php_shim::fseek(stderr, 0, shirabe_php_shim::SEEK_END); + shirabe_php_shim::fwrite(stderr, line, Some(line.len() as i64)); + shirabe_php_shim::fseek( + stderr, + self.incremental_error_output_offset, + shirabe_php_shim::SEEK_SET, + ); } /// Gets the last output time in seconds. @@ -953,7 +973,7 @@ impl Process { /// Enables or disables the TTY mode. pub fn set_tty(&mut self, tty: bool) -> anyhow::Result<&mut Self> { - if php::DIRECTORY_SEPARATOR == "\\" && tty { + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" && tty { return Err(RuntimeException::new( "TTY mode is not supported on Windows platform.".to_string(), ) @@ -994,7 +1014,7 @@ impl Process { if self.cwd.is_none() { // getcwd() will return false if any one of the parent directories does not have // the readable or search mode set, even if the current directory does - return php::getcwd().filter(|s| !s.is_empty()); + return shirabe_php_shim::getcwd().filter(|s| !s.is_empty()); } self.cwd.clone() @@ -1046,7 +1066,7 @@ impl Process { } if let Some(timeout) = self.timeout - && timeout < php::microtime() - self.starttime.unwrap_or(0.0) + && timeout < shirabe_php_shim::microtime() - self.starttime.unwrap_or(0.0) { self.stop(0.0, None); @@ -1058,7 +1078,7 @@ impl Process { } if let Some(idle_timeout) = self.idle_timeout - && idle_timeout < php::microtime() - self.last_output_time.unwrap_or(0.0) + && idle_timeout < shirabe_php_shim::microtime() - self.last_output_time.unwrap_or(0.0) { self.stop(0.0, None); @@ -1119,7 +1139,7 @@ impl Process { *IS_TTY_SUPPORTED.get_or_init(|| { let mut pipes = IndexMap::new(); - php::proc_open( + shirabe_php_shim::proc_open( "echo 1 >/dev/null", &[ descriptor(&["file", "/dev/tty", "r"]), @@ -1140,12 +1160,12 @@ impl Process { static RESULT: OnceLock = OnceLock::new(); *RESULT.get_or_init(|| { - if php::DIRECTORY_SEPARATOR == "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { return false; } let mut pipes = IndexMap::new(); - php::proc_open( + shirabe_php_shim::proc_open( "echo 1 >/dev/null", &[ descriptor(&["pty"]), @@ -1164,7 +1184,7 @@ impl Process { /// Creates the descriptors needed by the proc_open. fn get_descriptors(&mut self) -> Vec { // TODO(plugin): $this->input instanceof \Iterator -> rewind() is not modeled. - if php::DIRECTORY_SEPARATOR == "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { self.process_pipes = Some(Box::new(WindowsPipes::new( self.input.clone(), !self.output_disabled || self.has_callback, @@ -1219,17 +1239,19 @@ impl Process { return; } - self.process_information = Some(php::proc_get_status(self.process.as_ref().unwrap())); + self.process_information = Some(shirabe_php_shim::proc_get_status( + self.process.as_ref().unwrap(), + )); let running = self .process_information .as_ref() .unwrap() .get("running") - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false); // In PHP < 8.3, "proc_get_status" only returns the correct exit status on the first call. - if php::PHP_VERSION_ID < 80300 { + if shirabe_php_shim::PHP_VERSION_ID < 80300 { let exitcode = self .process_information .as_ref() @@ -1253,7 +1275,7 @@ impl Process { self.read_pipes( running && blocking, - php::DIRECTORY_SEPARATOR != "\\" || !running, + shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" || !running, ); if !self.fallback_status.is_empty() && self.is_sigchild_enabled() { @@ -1278,16 +1300,16 @@ impl Process { return *v; } - if !php::function_exists("phpinfo") { + if !shirabe_php_shim::function_exists("phpinfo") { return *SIGCHILD.get_or_init(|| false); } - php::ob_start(); - php::phpinfo(php::INFO_GENERAL); + shirabe_php_shim::ob_start(); + shirabe_php_shim::phpinfo(shirabe_php_shim::INFO_GENERAL); *SIGCHILD.get_or_init(|| { - php::str_contains( - &php::ob_get_clean().unwrap_or_default(), + shirabe_php_shim::str_contains( + &shirabe_php_shim::ob_get_clean().unwrap_or_default(), "--enable-sigchild", ) }) @@ -1359,7 +1381,7 @@ impl Process { p.close(); } if self.process.is_some() { - php::proc_close(self.process.as_ref().unwrap()); + shirabe_php_shim::proc_close(self.process.as_ref().unwrap()); self.process = None; } self.exitcode = self @@ -1374,7 +1396,7 @@ impl Process { .process_information .as_ref() .and_then(|i| i.get("signaled")) - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false); let termsig = self .process_information @@ -1407,10 +1429,14 @@ impl Process { self.fallback_status = IndexMap::new(); self.process_information = None; // php://temp is an in-memory stream; fopen never fails for it. - self.stdout = - Some(php::fopen(&format!("php://temp/maxmemory:{}", 1024 * 1024), "w+").unwrap()); - self.stderr = - Some(php::fopen(&format!("php://temp/maxmemory:{}", 1024 * 1024), "w+").unwrap()); + self.stdout = Some( + shirabe_php_shim::fopen(&format!("php://temp/maxmemory:{}", 1024 * 1024), "w+") + .unwrap(), + ); + self.stderr = Some( + shirabe_php_shim::fopen(&format!("php://temp/maxmemory:{}", 1024 * 1024), "w+") + .unwrap(), + ); self.process = None; self.latest_signal = None; self.status = Self::STATUS_READY.to_string(); @@ -1434,10 +1460,10 @@ impl Process { Some(pid) => pid, }; - if php::DIRECTORY_SEPARATOR == "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR == "\\" { let mut output: Vec = Vec::new(); let mut exit_code: i64 = 0; - php::exec( + shirabe_php_shim::exec( &format!("taskkill /F /T /PID {} 2>&1", pid), Some(&mut output), Some(&mut exit_code), @@ -1456,12 +1482,12 @@ impl Process { } else { let ok; if !self.is_sigchild_enabled() { - ok = php::proc_terminate(self.process.as_ref().unwrap(), signal); - } else if php::function_exists("posix_kill") { - ok = php::posix_kill(pid, signal); + ok = shirabe_php_shim::proc_terminate(self.process.as_ref().unwrap(), signal); + } else if shirabe_php_shim::function_exists("posix_kill") { + ok = shirabe_php_shim::posix_kill(pid, signal); } else { let mut pipes = IndexMap::new(); - let opened = php::proc_open( + let opened = shirabe_php_shim::proc_open( &format!("kill -{} {}", signal, pid), &[ Descriptor::Inherit, @@ -1474,7 +1500,10 @@ impl Process { None, ); ok = match opened { - Ok(_) => pipes.get(&2).and_then(|p| php::fgets(p, None)).is_none(), + Ok(_) => pipes + .get(&2) + .and_then(|p| shirabe_php_shim::fgets(p, None)) + .is_none(), Err(_) => false, }; } @@ -1509,10 +1538,10 @@ impl Process { cmd: &str, env: &mut IndexMap, ) -> anyhow::Result { - let uid = php::uniqid("", true); + let uid = shirabe_php_shim::uniqid("", true); let mut var_count = 0; let mut var_cache: IndexMap = IndexMap::new(); - let cmd = php::preg_replace_callback( + let cmd = shirabe_php_shim::preg_replace_callback( r#"/"(?:( [^"%!^]*+ (?: @@ -1533,7 +1562,7 @@ impl Process { if value.contains('\0') { value = value.replace('\0', "?"); } - if php::strpbrk(&value, "\"%!\n").is_none() { + if shirabe_php_shim::strpbrk(&value, "\"%!\n").is_none() { return Ok(format!("\"{}\"", value)); } @@ -1548,7 +1577,7 @@ impl Process { } value = format!( "\"{}\"", - php::preg_replace(r#"/(\\*)"/"#, "$1$1\\\"", &value) + shirabe_php_shim::preg_replace(r#"/(\\*)"/"#, "$1$1\\\"", &value) ); var_count += 1; let var = format!("{}{}", uid, var_count); @@ -1570,7 +1599,7 @@ impl Process { .map(|spec| { format!( "\"{}\"", - php::preg_replace(r#"{(\\*+)"}"#, "$1$1\\\"", &spec) + shirabe_php_shim::preg_replace(r#"{(\\*+)"}"#, "$1$1\\\"", &spec) ) }) }) @@ -1618,17 +1647,21 @@ impl Process { None | Some("") => return "\"\"".to_string(), Some(a) => a, }; - if php::DIRECTORY_SEPARATOR != "\\" { + if shirabe_php_shim::DIRECTORY_SEPARATOR != "\\" { return format!("'{}'", argument.replace('\'', "'\\''")); } let mut argument = argument.to_string(); if argument.contains('\0') { argument = argument.replace('\0', "?"); } - if !php::preg_match(r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#, &argument, &mut Vec::new()) { + if !shirabe_php_shim::preg_match( + r#"/[()%!^"<>&|\s\[\]=;*?'$]/"#, + &argument, + &mut Vec::new(), + ) { return argument; } - argument = php::preg_replace(r"/(\\+)$/", "$1$1", &argument); + argument = shirabe_php_shim::preg_replace(r"/(\\+)$/", "$1$1", &argument); let mut result = argument; for (from, to) in [ @@ -1648,7 +1681,7 @@ impl Process { commandline: &str, env: &IndexMap, ) -> anyhow::Result { - php::preg_replace_callback( + shirabe_php_shim::preg_replace_callback( r#"/"\$\{:([_a-zA-Z]+[_a-zA-Z0-9]*)\}"/"#, |matches: &[Option]| -> anyhow::Result { let key = matches.get(1).cloned().flatten().unwrap_or_default(); @@ -1671,7 +1704,7 @@ impl Process { } fn get_default_env(&self) -> IndexMap { - let env: IndexMap = php::getenv_all() + let env: IndexMap = shirabe_php_shim::getenv_all() .map(|(k, v)| { ( k.to_string_lossy().into_owned(), @@ -1679,7 +1712,7 @@ impl Process { ) }) .collect(); - let server = php::PHP_SERVER.lock().unwrap(); + let server = shirabe_php_shim::PHP_SERVER.lock().unwrap(); // non-Windows: array_intersect_key($env, $_SERVER) ?: $env let mut intersect: IndexMap = IndexMap::new(); @@ -1697,7 +1730,7 @@ impl Process { }; // $_ENV + env_map - let mut result: IndexMap = php::PHP_ENV + let mut result: IndexMap = shirabe_php_shim::PHP_ENV .lock() .unwrap() .get_all() @@ -1739,7 +1772,7 @@ impl Drop for Process { if self .options .get("create_new_console") - .map(php::php_truthy) + .map(shirabe_php_shim::php_truthy) .unwrap_or(false) { if let Some(p) = self.process_pipes.as_mut() { diff --git a/crates/shirabe-external-packages/src/symfony/process/process_utils.rs b/crates/shirabe-external-packages/src/symfony/process/process_utils.rs index 7287b28..71943b8 100644 --- a/crates/shirabe-external-packages/src/symfony/process/process_utils.rs +++ b/crates/shirabe-external-packages/src/symfony/process/process_utils.rs @@ -1,8 +1,7 @@ //! ref: composer/vendor/symfony/process/ProcessUtils.php -use shirabe_php_shim::{self as php, PhpMixed}; - use crate::symfony::process::exception::invalid_argument_exception::InvalidArgumentException; +use shirabe_php_shim::PhpMixed; /// ProcessUtils is a bunch of utility methods. #[derive(Debug)] @@ -12,10 +11,10 @@ impl ProcessUtils { /// Validates and normalizes a Process input. pub fn validate_input(caller: &str, input: PhpMixed) -> anyhow::Result { if !input.is_null() { - if php::is_string(&input) { + if shirabe_php_shim::is_string(&input) { return Ok(input); } - if php::is_scalar(&input) { + if shirabe_php_shim::is_scalar(&input) { let s = match &input { PhpMixed::Bool(b) => { if *b { diff --git a/crates/shirabe-external-packages/src/symfony/string.rs b/crates/shirabe-external-packages/src/symfony/string.rs new file mode 100644 index 0000000..139d726 --- /dev/null +++ b/crates/shirabe-external-packages/src/symfony/string.rs @@ -0,0 +1,17 @@ +pub mod byte_string; +pub mod code_point_string; +pub mod unicode_string; + +pub use byte_string::*; +pub use code_point_string::*; +pub use unicode_string::*; + +/// Mirror of Symfony's `b()` helper function. +pub fn b(string: &str) -> ByteString { + ByteString::new(string) +} + +/// Mirror of Symfony's `u()` helper function. +pub fn s(string: &str) -> UnicodeString { + UnicodeString::new(string) +} diff --git a/crates/shirabe-external-packages/src/symfony/string/mod.rs b/crates/shirabe-external-packages/src/symfony/string/mod.rs deleted file mode 100644 index 139d726..0000000 --- a/crates/shirabe-external-packages/src/symfony/string/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -pub mod byte_string; -pub mod code_point_string; -pub mod unicode_string; - -pub use byte_string::*; -pub use code_point_string::*; -pub use unicode_string::*; - -/// Mirror of Symfony's `b()` helper function. -pub fn b(string: &str) -> ByteString { - ByteString::new(string) -} - -/// Mirror of Symfony's `u()` helper function. -pub fn s(string: &str) -> UnicodeString { - UnicodeString::new(string) -} -- cgit v1.3.1