diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-06 10:37:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-06 10:37:12 +0900 |
| commit | d9dca94603766712b5989ea8169c9e286d27a60c (patch) | |
| tree | b8c75845bf2d93771c91c7d7058a0ed041f94edc /crates/shirabe-php-shim | |
| parent | 70e463708b461efd61a611061cfee0539d28645a (diff) | |
| download | php-shirabe-d9dca94603766712b5989ea8169c9e286d27a60c.tar.gz php-shirabe-d9dca94603766712b5989ea8169c9e286d27a60c.tar.zst php-shirabe-d9dca94603766712b5989ea8169c9e286d27a60c.zip | |
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim')
| -rw-r--r-- | crates/shirabe-php-shim/src/fs.rs | 8 |
1 files changed, 3 insertions, 5 deletions
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<std::path::Path>) -> Option<PhpDirHandle> { }) } -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<PathBuf> |
