diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-20 14:53:23 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-20 15:08:49 +0900 |
| commit | 8313c66b5b07e7b8af8db8faa044a0b3a1783fa1 (patch) | |
| tree | 4add563bca8f6c8188a9fd675288684660e0f3a6 /crates/shirabe-php-shim/src | |
| parent | 6c30a3e065b4d7f597331b0b79a226f8e3480976 (diff) | |
| download | php-shirabe-8313c66b5b07e7b8af8db8faa044a0b3a1783fa1.tar.gz php-shirabe-8313c66b5b07e7b8af8db8faa044a0b3a1783fa1.tar.zst php-shirabe-8313c66b5b07e7b8af8db8faa044a0b3a1783fa1.zip | |
feat(php-shim): implement is_numeric
Was a todo!() that panicked when ProcessExecutor::reset_max_jobs probed
COMPOSER_MAX_PARALLEL_PROCESSES (archive, diagnose, init, ...). Ints and
floats are numeric; strings delegate to the existing is_numeric_string,
which agrees with PHP across the tested vectors. Booleans, null and
arrays are not numeric.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/lib.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/shirabe-php-shim/src/lib.rs b/crates/shirabe-php-shim/src/lib.rs index 381a56a..4b2ea87 100644 --- a/crates/shirabe-php-shim/src/lib.rs +++ b/crates/shirabe-php-shim/src/lib.rs @@ -468,8 +468,12 @@ pub fn is_scalar(_value: &PhpMixed) -> bool { ) } -pub fn is_numeric(_value: &PhpMixed) -> bool { - todo!() +pub fn is_numeric(value: &PhpMixed) -> bool { + match value { + PhpMixed::Int(_) | PhpMixed::Float(_) => true, + PhpMixed::String(s) => is_numeric_string(s), + _ => false, + } } pub fn strtotime(_time: &str) -> Option<i64> { |
