## Category `stdlib` | `runtime` ## Problem Same class of Zend mismatch as **#4135** (`array_key_exists` / `in_array` / `array_search`): non-array input must raise **`TypeError`**, not `LogicException`. `array_keys()` and `array_values()` currently use build-specific `LogicException` messages when the array argument is not an array (including objects). ## php-src reference - [php/php-src `ext/standard/array.c`](https://github.com/php/php-src/blob/master/ext/standard/array.c) — `PHP_FUNCTION(array_keys)`, `PHP_FUNCTION(array_values)` ## Repro ```php <?php $o = new stdClass(); foreach (['array_keys', 'array_values'] as $fn) { try { $fn($o); } catch (TypeError $e) { echo "$fn: TypeError\n"; } catch (Throwable $e) { echo "$fn: ", get_class($e), "\n"; } } ``` ```bash ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php' ``` | Runtime | `array_keys($o)` | |---------|------------------| | Zend PHP 8.x | `TypeError: array_keys(): Argument #1 ($array) must be of type array, stdClass given` | | This compiler | `LogicException: ... must be an array in this compiler build` | ## Scope | Files | |-------| | `ext/standard/array_keys.php`, `array_values.php` | | JIT helpers if array builtins inline type checks | | PHPT under `test/compliance/cases/stdlib/` | ## Done when - [ ] Repro reports `TypeError` for both functions on VM - [ ] Coordinate message format with **#4135** (shared helper for array-arg TypeError) - [ ] `./script/ci-fast.sh --filter array_keys_type` green ## Links - **#4135** (sibling builtins) · **#195** (Error types)
Category
stdlib|runtimeProblem
Same class of Zend mismatch as #4135 (
array_key_exists/in_array/array_search): non-array input must raiseTypeError, notLogicException.array_keys()andarray_values()currently use build-specificLogicExceptionmessages when the array argument is not an array (including objects).php-src reference
ext/standard/array.c—PHP_FUNCTION(array_keys),PHP_FUNCTION(array_values)Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'array_keys($o)TypeError: array_keys(): Argument #1 ($array) must be of type array, stdClass givenLogicException: ... must be an array in this compiler buildScope
ext/standard/array_keys.php,array_values.phptest/compliance/cases/stdlib/Done when
TypeErrorfor both functions on VM./script/ci-fast.sh --filter array_keys_typegreenLinks