aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/autoload
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-27 03:52:05 +0900
committernsfisis <nsfisis@gmail.com>2026-06-27 04:21:34 +0900
commit2b51554ff59d1e5cbf8dd2db65d278b0202a9102 (patch)
treef4d9b0abf4df9b5e363e3bd65511d70e3d5ada00 /crates/shirabe/src/autoload
parentcc07b5abb83a40d678401c335bdc49bb81b72c5f (diff)
downloadphp-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.gz
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.tar.zst
php-shirabe-2b51554ff59d1e5cbf8dd2db65d278b0202a9102.zip
refactor: fix compiler warnings and clippy warnings
Diffstat (limited to 'crates/shirabe/src/autoload')
-rw-r--r--crates/shirabe/src/autoload/autoload_generator.rs23
-rw-r--r--crates/shirabe/src/autoload/class_loader.rs3
2 files changed, 11 insertions, 15 deletions
diff --git a/crates/shirabe/src/autoload/autoload_generator.rs b/crates/shirabe/src/autoload/autoload_generator.rs
index 1910136..1bdea07 100644
--- a/crates/shirabe/src/autoload/autoload_generator.rs
+++ b/crates/shirabe/src/autoload/autoload_generator.rs
@@ -7,14 +7,12 @@ use shirabe_class_map_generator::class_map_generator::ClassMapGenerator;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
use shirabe_php_shim::{
- InvalidArgumentException, PhpMixed, RuntimeException, array_filter, array_keys, array_map,
- array_merge, array_merge_map, array_merge_recursive, array_reverse, array_shift, array_slice,
- array_slice_strs, array_unique, bin2hex, explode, file_exists, file_get_contents, hash,
- implode, in_array, is_array, krsort, ksort, ltrim, preg_quote, random_bytes, realpath, sprintf,
- str_contains, str_replace, str_starts_with, strlen, strpos, strtr, substr, substr_count, trim,
- unlink, var_export,
+ InvalidArgumentException, PhpMixed, array_keys, array_map, array_merge_map,
+ array_merge_recursive, array_shift, array_slice_strs, array_unique, bin2hex, explode,
+ file_exists, file_get_contents, hash, implode, is_array, ksort, ltrim, preg_quote,
+ random_bytes, realpath, str_contains, str_replace, str_starts_with, strlen, strpos, strtr,
+ substr, substr_count, trim, unlink, var_export,
};
-use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::Bound;
use crate::autoload::ClassLoader;
@@ -29,7 +27,6 @@ use crate::io::IOInterfaceImmutable;
use crate::io::NullIO;
use crate::json::JsonFile;
use crate::package::Locker;
-use crate::package::PackageInterface;
use crate::package::PackageInterfaceHandle;
use crate::package::RootPackageInterfaceHandle;
use crate::repository::InstalledRepositoryInterface;
@@ -516,7 +513,7 @@ impl AutoloadGenerator {
if suffix.is_none() && Filesystem::is_readable(&format!("{}/autoload.php", vendor_path))
{
let content =
- file_get_contents(&format!("{}/autoload.php", vendor_path)).unwrap_or_default();
+ file_get_contents(format!("{}/autoload.php", vendor_path)).unwrap_or_default();
let mut matches: IndexMap<CaptureKey, String> = IndexMap::new();
if Preg::match3(
"{ComposerAutoloaderInit([^:\\s]+)::}",
@@ -624,8 +621,8 @@ impl AutoloadGenerator {
&format!("{}/platform_check.php", target_dir),
platform_check_content.as_ref().unwrap(),
)?;
- } else if file_exists(&format!("{}/platform_check.php", target_dir)) {
- unlink(&format!("{}/platform_check.php", target_dir));
+ } else if file_exists(format!("{}/platform_check.php", target_dir)) {
+ unlink(format!("{}/platform_check.php", target_dir));
}
filesystem.file_put_contents_if_modified(
&format!("{}/autoload.php", vendor_path),
@@ -1562,7 +1559,7 @@ impl AutoloadGenerator {
let prefix = "\0Composer\\Autoload\\ClassLoader\0";
let prefix_len = strlen(prefix);
let mut maps: IndexMap<String, PhpMixed> = IndexMap::new();
- if file_exists(&format!("{}/autoload_files.php", target_dir)) {
+ if file_exists(format!("{}/autoload_files.php", target_dir)) {
maps.insert(
"files".to_string(),
require_generated_php_array(&format!("{}/autoload_files.php", target_dir)),
@@ -1687,7 +1684,7 @@ impl AutoloadGenerator {
};
// PHP: foreach ((array) $paths as $path) — handles scalar by wrapping in an array
let path_list: Vec<PhpMixed> = match &paths {
- PhpMixed::List(l) => l.iter().cloned().collect(),
+ PhpMixed::List(l) => l.to_vec(),
PhpMixed::Array(a) => a.values().cloned().collect(),
other => vec![other.clone()],
};
diff --git a/crates/shirabe/src/autoload/class_loader.rs b/crates/shirabe/src/autoload/class_loader.rs
index daa5d97..3889ca0 100644
--- a/crates/shirabe/src/autoload/class_loader.rs
+++ b/crates/shirabe/src/autoload/class_loader.rs
@@ -4,8 +4,7 @@ use indexmap::IndexMap;
use std::sync::{LazyLock, Mutex};
use shirabe_php_shim::{
- DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, array_merge, array_values,
- call_user_func_array, defined, file_exists, function_exists, include_file, ini_get,
+ DIRECTORY_SEPARATOR, InvalidArgumentException, PhpMixed, defined, file_exists, include_file,
spl_autoload_register, spl_autoload_unregister, stream_resolve_include_path, strlen, strpos,
strrpos, strtr, substr,
};