aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-21 17:02:52 +0900
committernsfisis <nsfisis@gmail.com>2026-06-21 17:12:37 +0900
commit84fe6ac6977f15cbec85cbc9f773567742a7fb87 (patch)
tree5701e7c980585dd404471ab9fa53e98a0ba601ab /crates
parent12a7756588a20f1351e6976f0c009de5992514a9 (diff)
downloadphp-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.tar.gz
php-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.tar.zst
php-shirabe-84fe6ac6977f15cbec85cbc9f773567742a7fb87.zip
refactor(math): use method-style max/min/clamp over std::cmp
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs2
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs19
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/table.rs7
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/output/console_section_output.rs6
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs18
-rw-r--r--crates/shirabe-php-shim/src/math.rs24
-rw-r--r--crates/shirabe-semver/src/version_parser.rs2
-rw-r--r--crates/shirabe/src/cache.rs8
-rw-r--r--crates/shirabe/src/command/base_command.rs4
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs8
-rw-r--r--crates/shirabe/src/config.rs20
-rw-r--r--crates/shirabe/src/console/application.rs6
-rw-r--r--crates/shirabe/src/dependency_resolver/pool.rs4
-rw-r--r--crates/shirabe/src/dependency_resolver/rule.rs4
-rw-r--r--crates/shirabe/src/event_dispatcher/event_dispatcher.rs4
-rw-r--r--crates/shirabe/src/installer.rs2
-rw-r--r--crates/shirabe/src/json/json_manipulator.rs6
-rw-r--r--crates/shirabe/src/repository/vcs/svn_driver.rs6
-rw-r--r--crates/shirabe/src/util/http/curl_downloader.rs12
-rw-r--r--crates/shirabe/src/util/http_downloader.rs17
-rw-r--r--crates/shirabe/src/util/no_proxy_pattern.rs6
-rw-r--r--crates/shirabe/src/util/process_executor.rs17
-rw-r--r--crates/shirabe/src/util/remote_filesystem.rs7
23 files changed, 90 insertions, 119 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
index 421cf52..097d7f4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/descriptor/text_descriptor.rs
@@ -529,7 +529,7 @@ impl TextDescriptor {
for option in options {
// "-" + shortcut + ", --" + name
let mut name_length = 1
- + std::cmp::max(Helper::width(option.get_shortcut().unwrap_or("")), 1)
+ + Helper::width(option.get_shortcut().unwrap_or("")).max(1)
+ 4
+ Helper::width(option.get_name());
if option.is_negatable() {
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
index d9b808e..d9d3fd6 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/progress_bar.rs
@@ -225,11 +225,10 @@ impl ProgressBar {
}
pub fn get_bar_offset(&self) -> f64 {
- shirabe_php_shim::floor(if self.max != 0 {
+ f64::floor(if self.max != 0 {
self.percent * self.bar_width as f64
} else if self.redraw_freq.is_none() {
- ((shirabe_php_shim::min(5, self.bar_width / 15) * self.write_count) % self.bar_width)
- as f64
+ (((self.bar_width / 15).min(5) * self.write_count) % self.bar_width) as f64
} else {
(self.step % self.bar_width) as f64
})
@@ -260,7 +259,7 @@ impl ProgressBar {
}
pub fn set_bar_width(&mut self, size: i64) {
- self.bar_width = shirabe_php_shim::max(1, size);
+ self.bar_width = size.max(1);
}
pub fn get_bar_width(&self) -> i64 {
@@ -309,7 +308,7 @@ impl ProgressBar {
///
/// `$freq` The frequency in steps
pub fn set_redraw_frequency(&mut self, freq: Option<i64>) {
- self.redraw_freq = freq.map(|freq| shirabe_php_shim::max(1, freq));
+ self.redraw_freq = freq.map(|freq| freq.max(1));
}
pub fn min_seconds_between_redraws(&mut self, seconds: f64) {
@@ -416,7 +415,7 @@ impl ProgressBar {
pub fn set_max_steps(&mut self, max: i64) {
self.format = None;
- self.max = shirabe_php_shim::max(0, max);
+ self.max = max.max(0);
self.step_width = if self.max != 0 {
Helper::width(&self.max.to_string())
} else {
@@ -512,9 +511,9 @@ impl ProgressBar {
message_line,
));
if message_line_length > self.terminal.get_width() {
- line_count += shirabe_php_shim::floor(
- message_line_length as f64 / self.terminal.get_width() as f64,
- ) as i64;
+ line_count += (message_line_length as f64
+ / self.terminal.get_width() as f64)
+ .floor() as i64;
}
}
todo!("$this->output->clear($lineCount); (ConsoleSectionOutput)");
@@ -699,7 +698,7 @@ impl ProgressBar {
Box::new(
|bar: &ProgressBar, _output: &Rc<RefCell<dyn OutputInterface>>| {
Ok(Ok(shirabe_php_shim::PhpMixed::Float(
- shirabe_php_shim::floor(bar.get_progress_percent() * 100.0),
+ (bar.get_progress_percent() * 100.0).floor(),
)))
},
),
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
index 678831a..9c868c4 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
@@ -558,7 +558,7 @@ impl Table {
);
}
- let title_start = shirabe_php_shim::intdiv(markup_length - title_length, 2);
+ let title_start = (markup_length - title_length) / 2;
if shirabe_php_shim::mb_detect_encoding(&markup, None, true).is_none() {
markup = shirabe_php_shim::substr_replace(
&markup,
@@ -1087,9 +1087,8 @@ impl Table {
if text_length > 0 {
let content_columns = shirabe_php_shim::mb_str_split(
&text_content,
- shirabe_php_shim::ceil(
- text_length as f64 / Self::cell_colspan(&cell) as f64,
- ) as i64,
+ (text_length as f64 / Self::cell_colspan(&cell) as f64).ceil()
+ as i64,
);
for (position, content) in content_columns.into_iter().enumerate() {
Self::vec_set(
diff --git a/crates/shirabe-external-packages/src/symfony/console/output/console_section_output.rs b/crates/shirabe-external-packages/src/symfony/console/output/console_section_output.rs
index d05d0a4..3120775 100644
--- a/crates/shirabe-external-packages/src/symfony/console/output/console_section_output.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/output/console_section_output.rs
@@ -92,9 +92,9 @@ impl ConsoleSectionOutput {
/// @internal
pub fn add_content(&self, input: &str) {
for line_content in shirabe_php_shim::explode(shirabe_php_shim::PHP_EOL, input) {
- let count = shirabe_php_shim::ceil(
- self.get_display_length(&line_content) as f64 / self.terminal.get_width() as f64,
- );
+ let count = (self.get_display_length(&line_content) as f64
+ / self.terminal.get_width() as f64)
+ .ceil();
self.lines
.set(self.lines.get() + if count != 0.0 { count as i64 } else { 1 });
self.content.borrow_mut().push(line_content);
diff --git a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
index ce08f45..83229a9 100644
--- a/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/style/symfony_style.rs
@@ -61,7 +61,7 @@ impl SymfonyStyle {
let w = Terminal::new().get_width();
if w != 0 { w } else { MAX_LINE_LENGTH }
};
- let line_length = shirabe_php_shim::min(
+ let line_length = std::cmp::min(
width - (std::path::MAIN_SEPARATOR == '\\') as i64,
MAX_LINE_LENGTH,
);
@@ -350,7 +350,7 @@ impl SymfonyStyle {
&mut *self.get_formatter().borrow_mut(),
&message,
));
- let message_line_length = shirabe_php_shim::min(
+ let message_line_length = std::cmp::min(
self.line_length - prefix_length - indent_length + decoration_length,
self.line_length,
);
@@ -392,14 +392,12 @@ impl SymfonyStyle {
*line = format!("{}{}", prefix, line);
line.push_str(&shirabe_php_shim::str_repeat(
" ",
- shirabe_php_shim::max(
- self.line_length
- - Helper::width(&Helper::remove_decoration(
- &mut *self.output.borrow().get_formatter().borrow_mut(),
- line,
- )),
- 0,
- ) as usize,
+ (self.line_length
+ - Helper::width(&Helper::remove_decoration(
+ &mut *self.output.borrow().get_formatter().borrow_mut(),
+ line,
+ )))
+ .max(0) as usize,
));
if let Some(style) = style {
diff --git a/crates/shirabe-php-shim/src/math.rs b/crates/shirabe-php-shim/src/math.rs
index ee9a76d..0d9090b 100644
--- a/crates/shirabe-php-shim/src/math.rs
+++ b/crates/shirabe-php-shim/src/math.rs
@@ -1,30 +1,6 @@
-pub fn max(a: i64, b: i64) -> i64 {
- a.max(b)
-}
-
-pub fn min(a: i64, b: i64) -> i64 {
- a.min(b)
-}
-
-pub fn abs(v: i64) -> i64 {
- v.abs()
-}
-
-pub fn floor(v: f64) -> f64 {
- v.floor()
-}
-
-pub fn ceil(v: f64) -> f64 {
- v.ceil()
-}
-
pub fn round(v: f64, precision: i64) -> f64 {
// PHP's default mode is PHP_ROUND_HALF_UP (round half away from zero),
// which matches Rust's f64::round.
let factor = 10f64.powi(precision as i32);
(v * factor).round() / factor
}
-
-pub fn intdiv(a: i64, b: i64) -> i64 {
- a / b
-}
diff --git a/crates/shirabe-semver/src/version_parser.rs b/crates/shirabe-semver/src/version_parser.rs
index 63abc00..ddde07e 100644
--- a/crates/shirabe-semver/src/version_parser.rs
+++ b/crates/shirabe-semver/src/version_parser.rs
@@ -446,7 +446,7 @@ impl VersionParser {
// For upper bound, we increment the position of one more significance,
// but highPosition = 0 would be illegal
- let high_position = std::cmp::max(1, position - 1);
+ let high_position = (position - 1).max(1);
let high_version = format!(
"{}-dev",
self.manipulate_version_string(&matches, high_position, 1, "0")
diff --git a/crates/shirabe/src/cache.rs b/crates/shirabe/src/cache.rs
index 315ba2c..8d9473a 100644
--- a/crates/shirabe/src/cache.rs
+++ b/crates/shirabe/src/cache.rs
@@ -7,9 +7,9 @@ use chrono::Utc;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::finder::Finder;
use shirabe_php_shim::{
- ErrorException, abs, bin2hex, clearstatcache, date_format_to_strftime, dirname,
- disk_free_space, 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,
+ ErrorException, bin2hex, clearstatcache, date_format_to_strftime, dirname, disk_free_space,
+ 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;
@@ -308,7 +308,7 @@ impl Cache {
if file_exists(&full_path)
&& let Some(mtime) = filemtime(&full_path)
{
- return Some(abs(time() - mtime));
+ return Some((time() - mtime).abs());
}
}
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index 40253d4..c4bfaef 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -13,7 +13,7 @@ use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
use shirabe_php_shim::{
AsAny, InvalidArgumentException, LogicException, PhpMixed, RuntimeException,
- UnexpectedValueException, count, explode, in_array, is_string, max,
+ UnexpectedValueException, count, explode, in_array, is_string,
};
use std::cell::RefCell;
use std::rc::Rc;
@@ -590,7 +590,7 @@ impl BaseCommand for BaseCommandData {
if Platform::is_windows() {
width -= 1;
} else {
- width = max(80, width);
+ width = width.max(80);
}
width
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 304f26f..43e878d 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -16,8 +16,8 @@ use shirabe_php_shim::{
PHP_WINDOWS_VERSION_BUILD, PhpMixed, RuntimeException, count, curl_version, defined,
disk_free_space, extension_loaded, file_exists, filter_var, function_exists, get_class,
get_class_err, hash, implode, ini_get, ioncube_loader_iversion, ioncube_loader_version,
- is_array, is_string, key, max, ob_get_clean, ob_start, phpinfo, reset, rtrim, sprintf,
- str_contains, str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare,
+ is_array, is_string, key, ob_get_clean, ob_start, phpinfo, reset, rtrim, sprintf, str_contains,
+ str_replace, str_starts_with, strpos, strstr, strtolower, trim, version_compare,
};
use std::cell::RefCell;
use std::rc::Rc;
@@ -1141,9 +1141,9 @@ impl DiagnoseCommand {
}
// Apply exit code updates after io borrow ends
if had_error {
- self.exit_code = max(prev_exit_code, 2);
+ self.exit_code = prev_exit_code.max(2);
} else if had_warning {
- self.exit_code = max(prev_exit_code, 1);
+ self.exit_code = prev_exit_code.max(1);
}
}
diff --git a/crates/shirabe/src/config.rs b/crates/shirabe/src/config.rs
index 2c39db5..b65961e 100644
--- a/crates/shirabe/src/config.rs
+++ b/crates/shirabe/src/config.rs
@@ -14,8 +14,7 @@ use shirabe_php_shim::{
E_USER_DEPRECATED, FILTER_VALIDATE_URL, PHP_URL_HOST, PHP_URL_SCHEME, PhpMixed,
RuntimeException, array_key_exists, array_merge, array_reverse, array_search_mixed,
array_unique, current, empty, filter_var, implode, in_array, is_array, is_int, is_string, key,
- max, parse_url, php_to_string, reset, rtrim, strtolower, strtoupper, strtr, substr,
- trigger_error,
+ parse_url, php_to_string, reset, rtrim, strtolower, strtoupper, strtr, substr, trigger_error,
};
use std::cell::RefCell;
@@ -587,7 +586,7 @@ impl Config {
} else {
val.clone()
};
- return Ok(PhpMixed::Int(max(0, raw.as_int().unwrap_or(0))));
+ return Ok(PhpMixed::Int(raw.as_int().unwrap_or(0).max(0)));
}
let raw_val = if matches!(val, PhpMixed::Bool(false)) {
@@ -647,10 +646,13 @@ impl Config {
}
// ints without env var support
- "cache-ttl" => Ok(PhpMixed::Int(max(
- 0,
- self.config.get(key).and_then(|v| v.as_int()).unwrap_or(0),
- ))),
+ "cache-ttl" => Ok(PhpMixed::Int(
+ self.config
+ .get(key)
+ .and_then(|v| v.as_int())
+ .unwrap_or(0)
+ .max(0),
+ )),
// numbers with kb/mb/gb support, without env var support
"cache-files-maxsize" => {
@@ -697,7 +699,7 @@ impl Config {
}
}
- Ok(PhpMixed::Int(max(0, size as i64)))
+ Ok(PhpMixed::Int((size as i64).max(0)))
}
// special cases below
@@ -706,7 +708,7 @@ impl Config {
if let Some(v) = v
&& !v.is_null()
{
- return Ok(PhpMixed::Int(max(0, v.as_int().unwrap_or(0))));
+ return Ok(PhpMixed::Int(v.as_int().unwrap_or(0).max(0)));
}
self.get_with_flags("cache-ttl", 0)
diff --git a/crates/shirabe/src/console/application.rs b/crates/shirabe/src/console/application.rs
index 22b857d..94f904f 100644
--- a/crates/shirabe/src/console/application.rs
+++ b/crates/shirabe/src/console/application.rs
@@ -56,7 +56,7 @@ use shirabe_php_shim::{
date_default_timezone_get, date_default_timezone_set, defined, dirname, disk_free_space,
error_get_last, extension_loaded, file_exists, file_get_contents, file_put_contents,
function_exists, get_class, getcwd, getmypid, glob, in_array, ini_set, is_array, is_dir,
- is_file, is_string, is_subclass_of, json_decode, max, memory_get_peak_usage, memory_get_usage,
+ is_file, is_string, is_subclass_of, json_decode, memory_get_peak_usage, memory_get_usage,
method_exists, microtime, php_uname, posix_getuid, random_bytes, realpath,
register_shutdown_function, restore_error_handler, round, sprintf, str_contains, str_replace,
strpos, strtoupper, sys_get_temp_dir, time, unlink,
@@ -2428,7 +2428,7 @@ impl Application {
// pre-format lines to get the right string length
let line_length = Helper::width(&line) + 4;
lines.push((line, line_length));
- len = shirabe_php_shim::max(line_length, len);
+ len = std::cmp::max(line_length, len);
}
}
@@ -2455,7 +2455,7 @@ impl Application {
title,
shirabe_php_shim::str_repeat(
" ",
- std::cmp::max(0, len - Helper::width(&title)) as usize
+ (len - Helper::width(&title)).max(0) as usize
)
));
}
diff --git a/crates/shirabe/src/dependency_resolver/pool.rs b/crates/shirabe/src/dependency_resolver/pool.rs
index 7b60002..b25f348 100644
--- a/crates/shirabe/src/dependency_resolver/pool.rs
+++ b/crates/shirabe/src/dependency_resolver/pool.rs
@@ -3,7 +3,7 @@
use std::fmt;
use indexmap::IndexMap;
-use shirabe_php_shim::{STR_PAD_LEFT, abs, str_pad};
+use shirabe_php_shim::{STR_PAD_LEFT, str_pad};
use shirabe_semver::compiling_matcher::CompilingMatcher;
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
@@ -280,7 +280,7 @@ impl Pool {
}
pub fn literal_to_package(&self, literal: i64) -> BasePackageHandle {
- let package_id = abs(literal);
+ let package_id = literal.abs();
self.package_by_id(package_id)
}
diff --git a/crates/shirabe/src/dependency_resolver/rule.rs b/crates/shirabe/src/dependency_resolver/rule.rs
index 30fa079..7686a3e 100644
--- a/crates/shirabe/src/dependency_resolver/rule.rs
+++ b/crates/shirabe/src/dependency_resolver/rule.rs
@@ -7,7 +7,7 @@ use std::rc::Rc;
use anyhow::Result;
use indexmap::IndexMap;
use shirabe_php_shim::{
- LogicException, PhpMixed, RuntimeException, abs, array_filter, array_keys, array_shift,
+ LogicException, PhpMixed, RuntimeException, array_filter, array_keys, array_shift,
array_values, implode, is_object,
};
use shirabe_semver::constraint::AnyConstraint;
@@ -554,7 +554,7 @@ impl Rule {
let mut installed_packages: Vec<BasePackageHandle> = vec![];
let mut removable_packages: Vec<BasePackageHandle> = vec![];
for literal in &literals {
- if installed_map.contains_key(&abs(*literal).to_string()) {
+ if installed_map.contains_key(&literal.abs().to_string()) {
installed_packages.push(pool.literal_to_package(*literal));
} else {
removable_packages.push(pool.literal_to_package(*literal));
diff --git a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
index bd14fea..d3b5fad 100644
--- a/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
+++ b/crates/shirabe/src/event_dispatcher/event_dispatcher.rs
@@ -9,7 +9,7 @@ use shirabe_php_shim::{
Exception, InvalidArgumentException, LogicException, PATH_SEPARATOR, PHP_VERSION_ID, PhpMixed,
RuntimeException, array_pop, array_push, array_search_in_vec, array_splice, class_exists,
count_mixed, defined, file_exists, get_class, hash, implode, ini_get, is_a, is_array,
- is_callable, is_object, is_string, krsort, max, method_exists, preg_quote, realpath,
+ is_callable, is_object, is_string, krsort, method_exists, preg_quote, realpath,
spl_autoload_functions, spl_autoload_register, spl_autoload_unregister, spl_object_hash,
sprintf, str_contains, str_ends_with, str_replace, str_starts_with, strlen, strpos, strtoupper,
substr, trim,
@@ -763,7 +763,7 @@ impl EventDispatcher {
}
}
- return_max = max(return_max, r#return);
+ return_max = std::cmp::max(return_max, r#return);
if event.is_propagation_stopped() {
break;
diff --git a/crates/shirabe/src/installer.rs b/crates/shirabe/src/installer.rs
index 6fe4f1f..8149b05 100644
--- a/crates/shirabe/src/installer.rs
+++ b/crates/shirabe/src/installer.rs
@@ -37,7 +37,7 @@ use shirabe_external_packages::seld::json_lint::ParsingException;
use shirabe_php_shim::{
PhpMixed, RuntimeException, array_flip, array_map, array_merge, array_unique, array_values,
clone, count, defined, gc_collect_cycles, gc_disable, gc_enable, get_class, implode, in_array,
- intval, is_dir, is_numeric, is_string, max, sprintf, strcmp, strpos, strtolower, touch, usort,
+ intval, is_dir, is_numeric, is_string, sprintf, strcmp, strpos, strtolower, touch, usort,
};
use shirabe_semver;
diff --git a/crates/shirabe/src/json/json_manipulator.rs b/crates/shirabe/src/json/json_manipulator.rs
index f5ad2cd..904ea7a 100644
--- a/crates/shirabe/src/json/json_manipulator.rs
+++ b/crates/shirabe/src/json/json_manipulator.rs
@@ -6,7 +6,7 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
ArrayObject, InvalidArgumentException, LogicException, PhpMixed, StdClass, addcslashes,
array_key_exists, array_keys, array_reverse, count, empty, explode, implode, in_array,
- is_array, is_int, is_numeric, json_decode, max, preg_quote, rtrim, str_contains, str_repeat,
+ is_array, is_int, is_numeric, json_decode, preg_quote, rtrim, str_contains, str_repeat,
str_replace, strlen, strnatcmp, strpos, substr, trim, uksort,
};
@@ -351,7 +351,7 @@ impl JsonManipulator {
list_regex = Some(format!(
"{{{}^(?P<start>\\s*\\{{\\s*(?:(?&string)\\s*:\\s*(?&json)\\s*,\\s*)*?\"repositories\"\\s*:\\s*\\[\\s*((?&json)\\s*+,\\s*+){{{}}})(?P<repository>(?&object))(?P<end>.*)}}sx",
Self::DEFINES,
- max(0, i_val)
+ i_val.max(0)
));
}
@@ -1251,7 +1251,7 @@ impl JsonManipulator {
let list_skip_to_item_regex = format!(
"{{{}^(?P<start>\\[\\s*((?&json)\\s*+,\\s*?){{{}}})(?P<space_before_item>(\\s*))(?P<end>.*)}}sx",
Self::DEFINES,
- max(0, index)
+ index.max(0)
);
let value_capture = value.clone();
diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs
index 96a1b38..e68beb6 100644
--- a/crates/shirabe/src/repository/vcs/svn_driver.rs
+++ b/crates/shirabe/src/repository/vcs/svn_driver.rs
@@ -5,7 +5,7 @@ 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, is_array, max, sprintf, stripos, strrpos, strtr,
+ PhpMixed, RuntimeException, array_key_exists, is_array, sprintf, stripos, strrpos, strtr,
substr, trim,
};
@@ -362,7 +362,7 @@ impl SvnDriver {
} else {
let identifier = self.build_identifier(
&format!("/{}/{}", self.tags_path, path),
- max(last_rev, rev),
+ std::cmp::max(last_rev, rev),
);
tags.insert(path.trim_end_matches('/').to_string(), identifier);
}
@@ -451,7 +451,7 @@ impl SvnDriver {
} else {
let identifier = self.build_identifier(
&format!("/{}/{}", self.branches_path, path),
- max(last_rev, rev),
+ std::cmp::max(last_rev, rev),
);
branches
.insert(path.trim_end_matches('/').to_string(), identifier);
diff --git a/crates/shirabe/src/util/http/curl_downloader.rs b/crates/shirabe/src/util/http/curl_downloader.rs
index 42153eb..0519f26 100644
--- a/crates/shirabe/src/util/http/curl_downloader.rs
+++ b/crates/shirabe/src/util/http/curl_downloader.rs
@@ -19,8 +19,8 @@ use shirabe_php_shim::{
curl_multi_add_handle, curl_multi_exec, curl_multi_info_read, curl_multi_init,
curl_multi_select, curl_multi_setopt, curl_setopt, curl_setopt_array, curl_share_init,
curl_share_setopt, curl_strerror, curl_version, defined, explode, fclose, fopen,
- function_exists, implode, in_array, ini_get, is_resource, json_decode, max, parse_url,
- preg_quote, rename, rewind, rtrim, sprintf, str_contains, stream_get_contents,
+ function_exists, implode, in_array, ini_get, is_resource, json_decode, parse_url, preg_quote,
+ rename, rewind, rtrim, sprintf, str_contains, stream_get_contents,
stream_get_contents_with_max, stripos, strpos, substr, unlink_silent, usleep, var_export,
};
@@ -369,14 +369,14 @@ impl CurlDownloader {
curl_setopt(
&curl_handle,
CURLOPT_TIMEOUT,
- PhpMixed::Int(max(
+ PhpMixed::Int(
ini_get("default_socket_timeout")
.as_deref()
.unwrap_or("0")
.parse::<i64>()
- .unwrap_or(0),
- 300,
- )),
+ .unwrap_or(0)
+ .max(300),
+ ),
);
curl_setopt(&curl_handle, CURLOPT_WRITEHEADER, header_handle.clone());
curl_setopt(&curl_handle, CURLOPT_FILE, body_handle.clone());
diff --git a/crates/shirabe/src/util/http_downloader.rs b/crates/shirabe/src/util/http_downloader.rs
index d5d619d..0c7308d 100644
--- a/crates/shirabe/src/util/http_downloader.rs
+++ b/crates/shirabe/src/util/http_downloader.rs
@@ -7,8 +7,8 @@ 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, max, min,
- rawurldecode, stream_context_create, stripos, strpos, substr, ucfirst,
+ extension_loaded, file_get_contents, function_exists, implode, is_numeric, rawurldecode,
+ stream_context_create, stripos, strpos, substr, ucfirst,
};
use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
@@ -148,13 +148,12 @@ impl HttpDownloader {
None => PhpMixed::Bool(false),
};
if is_numeric(&max_jobs_env_mixed) {
- max_jobs = max(
- 1,
- min(
- 50,
- max_jobs_env.as_deref().unwrap_or("0").parse().unwrap_or(0),
- ),
- );
+ max_jobs = max_jobs_env
+ .as_deref()
+ .unwrap_or("0")
+ .parse()
+ .unwrap_or(0)
+ .clamp(1, 50);
}
Self {
diff --git a/crates/shirabe/src/util/no_proxy_pattern.rs b/crates/shirabe/src/util/no_proxy_pattern.rs
index ed93414..08cd92f 100644
--- a/crates/shirabe/src/util/no_proxy_pattern.rs
+++ b/crates/shirabe/src/util/no_proxy_pattern.rs
@@ -6,8 +6,8 @@ use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
FILTER_VALIDATE_INT, FILTER_VALIDATE_IP, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_SCHEME, PhpMixed,
RuntimeException, array_key_exists, chr, empty, explode, filter_var, filter_var_with_options,
- floor, inet_pton, ltrim, parse_url, str_pad, str_repeat, stripos, strlen, strpbrk, strpos,
- substr, substr_count, unpack,
+ inet_pton, ltrim, parse_url, str_pad, str_repeat, stripos, strlen, strpbrk, strpos, substr,
+ substr_count, unpack,
};
/// Tests URLs against NO_PROXY patterns
@@ -314,7 +314,7 @@ impl NoProxyPattern {
fn ip_get_mask(&self, prefix: i64, size: i64) -> Vec<u8> {
let mut mask = String::new();
- let ones = floor(prefix as f64 / 8.0) as i64;
+ let ones = (prefix as f64 / 8.0).floor() as i64;
if ones != 0 {
mask = str_repeat(&chr(255), ones as usize);
}
diff --git a/crates/shirabe/src/util/process_executor.rs b/crates/shirabe/src/util/process_executor.rs
index 61fc0a1..1f15795 100644
--- a/crates/shirabe/src/util/process_executor.rs
+++ b/crates/shirabe/src/util/process_executor.rs
@@ -14,8 +14,8 @@ use shirabe_external_packages::symfony::process::exception::RuntimeException as
use shirabe_php_shim::{
LogicException, PhpMixed, RuntimeException, array_intersect, array_map, call_user_func,
defined, escapeshellarg, explode, implode, in_array, is_array, is_callable, is_dir, is_numeric,
- is_string, max, min, rtrim, sprintf, str_replace, strcspn, strlen, strpbrk, strtolower,
- strtr_array, substr_replace, trim, usleep,
+ is_string, rtrim, sprintf, str_replace, strcspn, strlen, strpbrk, strtolower, strtr_array,
+ substr_replace, trim, usleep,
};
use crate::io::IOInterface;
@@ -540,13 +540,12 @@ impl ProcessExecutor {
None => PhpMixed::Null,
};
if is_numeric(&max_jobs_env_mixed) {
- self.max_jobs = max(
- 1,
- min(
- 50,
- max_jobs_env.as_deref().unwrap_or("0").parse().unwrap_or(0),
- ),
- );
+ self.max_jobs = max_jobs_env
+ .as_deref()
+ .unwrap_or("0")
+ .parse()
+ .unwrap_or(0)
+ .clamp(1, 50);
} else {
self.max_jobs = 10;
}
diff --git a/crates/shirabe/src/util/remote_filesystem.rs b/crates/shirabe/src/util/remote_filesystem.rs
index c4b3923..bada2af 100644
--- a/crates/shirabe/src/util/remote_filesystem.rs
+++ b/crates/shirabe/src/util/remote_filesystem.rs
@@ -778,10 +778,9 @@ impl RemoteFilesystem {
}
x if x == STREAM_NOTIFY_PROGRESS => {
if self.bytes_max > 0 && self.progress {
- let progression = std::cmp::min(
- 100_i64,
- ((bytes_transferred as f64 / self.bytes_max as f64) * 100.0).round() as i64,
- );
+ let progression = (((bytes_transferred as f64 / self.bytes_max as f64) * 100.0)
+ .round() as i64)
+ .min(100_i64);
if 0 == progression % 5
&& 100 != progression