From d9dca94603766712b5989ea8169c9e286d27a60c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 6 Aug 2026 10:37:12 +0900 Subject: refactor(php-shim): take &str and return String from pathinfo pathinfo only ever receives a string and only ever returns one for the single-component options it supports, so the PhpMixed wrapping forced every call site to pack and unpack the value again. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe-php-shim/src/fs.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'crates/shirabe-php-shim/src') diff --git a/crates/shirabe-php-shim/src/fs.rs b/crates/shirabe-php-shim/src/fs.rs index ac7a4f99..c3f131b3 100644 --- a/crates/shirabe-php-shim/src/fs.rs +++ b/crates/shirabe-php-shim/src/fs.rs @@ -1075,9 +1075,8 @@ pub fn opendir(path: impl AsRef) -> Option { }) } -pub fn pathinfo(path: PhpMixed, option: i64) -> PhpMixed { - let path = path.as_string().unwrap_or(""); - let component = match option { +pub fn pathinfo(path: &str, option: i64) -> String { + match option { PATHINFO_DIRNAME => dirname(path), PATHINFO_BASENAME => basename(path), PATHINFO_EXTENSION => { @@ -1095,8 +1094,7 @@ pub fn pathinfo(path: PhpMixed, option: i64) -> PhpMixed { } } _ => unreachable!("pathinfo called with an unsupported single-component option"), - }; - PhpMixed::String(component) + } } // TODO(phase-c): returns Option -- cgit v1.3.1