diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-23 12:36:15 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-23 12:36:15 +0900 |
| commit | 890a50de2a740cc4c4edba12b37cc9aa4d0efdc5 (patch) | |
| tree | e9925bfa7874680dde9d229bc869867ad7779b8e /crates/shirabe-php-shim/src | |
| parent | 2f07bd12c0c77e8985646a9f21a62a91311d82c0 (diff) | |
| download | php-shirabe-890a50de2a740cc4c4edba12b37cc9aa4d0efdc5.tar.gz php-shirabe-890a50de2a740cc4c4edba12b37cc9aa4d0efdc5.tar.zst php-shirabe-890a50de2a740cc4c4edba12b37cc9aa4d0efdc5.zip | |
fix(config-command): print config values PHP would stringify
`config --list` and `config <key>` rendered a value with `as_string()`,
which yields None for everything but a string, so every int-valued
setting printed as an empty string: `cache-ttl`, `cache-files-ttl` and
the resolved value of `cache-files-maxsize`. PHP builds that output by
concatenating the value into the message, which casts it, so the ports
now go through `php_to_string`.
Two more differences in the same rendering path:
The `[a, b]` branch flattened the array through `as_list()`, which sees
only `PhpMixed::List`, so a keyed array reaching it rendered as `[]`.
PHP takes that branch whenever the first key is numeric, so the values
now come from `array_values_mixed`, which covers both representations.
The raw-vs-resolved comparison deciding between `raw (value)` and
`value` compared the two as strings. PHP compares with `!==`, which
also compares the type: with a `cache-ttl` of `"15552000"` in
composer.json, the raw string and the resolved int are not identical
and Composer prints `15552000 (15552000)`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src')
| -rw-r--r-- | crates/shirabe-php-shim/src/array.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/shirabe-php-shim/src/array.rs b/crates/shirabe-php-shim/src/array.rs index 3870d59e..ec9adb26 100644 --- a/crates/shirabe-php-shim/src/array.rs +++ b/crates/shirabe-php-shim/src/array.rs @@ -6,6 +6,14 @@ pub fn array_values<V: Clone>(array: &IndexMap<String, V>) -> Vec<V> { array.values().cloned().collect() } +pub fn array_values_mixed(value: &PhpMixed) -> Vec<PhpMixed> { + match value { + PhpMixed::List(items) => items.clone(), + PhpMixed::Array(map) => map.values().cloned().collect(), + _ => panic!("array_values(): Argument #1 ($array) must be of type array"), + } +} + pub fn array_keys<V>(array: &IndexMap<String, V>) -> Vec<String> { array.keys().cloned().collect() } |
