aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-05-12 04:13:13 +0900
committernsfisis <nsfisis@gmail.com>2026-05-12 04:13:13 +0900
commit185c22f61cbf26947276c6cc8ea5da1019b7b117 (patch)
tree06a5a1264f1b28e5637781bd123f5cd1f7443fec /crates/shirabe
parent7bfb3ff7cfbe10c4f096ea09671613731352723f (diff)
downloadphp-shirabe-185c22f61cbf26947276c6cc8ea5da1019b7b117.tar.gz
php-shirabe-185c22f61cbf26947276c6cc8ea5da1019b7b117.tar.zst
php-shirabe-185c22f61cbf26947276c6cc8ea5da1019b7b117.zip
feat(port): port IniHelper.php
Diffstat (limited to 'crates/shirabe')
-rw-r--r--crates/shirabe/src/util/ini_helper.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/crates/shirabe/src/util/ini_helper.rs b/crates/shirabe/src/util/ini_helper.rs
index c0125d9..e09b94f 100644
--- a/crates/shirabe/src/util/ini_helper.rs
+++ b/crates/shirabe/src/util/ini_helper.rs
@@ -1 +1,37 @@
//! ref: composer/src/Composer/Util/IniHelper.php
+
+use shirabe_external_packages::composer::xdebug_handler::xdebug_handler::XdebugHandler;
+
+pub struct IniHelper;
+
+impl IniHelper {
+ /// Returns an array of php.ini locations with at least one entry.
+ pub fn get_all() -> Vec<String> {
+ XdebugHandler::get_all_ini_files()
+ }
+
+ /// Describes the location of the loaded php.ini file(s).
+ pub fn get_message() -> String {
+ let mut paths = Self::get_all();
+
+ if paths.first().map_or(false, |s| s.is_empty()) {
+ paths.remove(0);
+ }
+
+ let ini = if paths.is_empty() {
+ String::new()
+ } else {
+ paths.remove(0)
+ };
+
+ if ini.is_empty() {
+ return "A php.ini file does not exist. You will have to create one.".to_string();
+ }
+
+ if !paths.is_empty() {
+ return "Your command-line PHP is using multiple ini files. Run `php --ini` to show them.".to_string();
+ }
+
+ format!("The php.ini used by your command-line PHP is: {}", ini)
+ }
+}