Summary
array_fill_keys([new stdClass()], 1) must fail with Error: Object of class stdClass could not be converted to string (object inside the keys array). VM mis-lowers the inline array literal and reports TypeError: … Argument #1 ($keys) must be of type array, stdClass given — as if the new expression were the $keys operand itself.
Using a variable works: array_fill_keys([$o], 1) reaches the correct Error.
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_array_fill_keys_inline_new.php
php bin/vm.php test/repro/maintainer_gap_array_fill_keys_inline_new.php'
| Call |
Zend PHP 8.2 |
VM today |
array_fill_keys([new stdClass()], 1) |
Error (object to string) |
TypeError on $keys type ❌ |
array_fill_keys([$o], 1) |
Error |
Error ✓ |
var_export([new stdClass()]) alone is fine — bug is call-site operand lowering, same family as #10093/#10775 inline literal gaps.
php-src reference
Implementation (PHP-in-PHP)
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_array_fill_keys_inline_new.php
Related: #10093, #10775, #8779, #1492
Summary
array_fill_keys([new stdClass()], 1)must fail withError: Object of class stdClass could not be converted to string(object inside the keys array). VM mis-lowers the inline array literal and reportsTypeError: … Argument #1 ($keys) must be of type array, stdClass given— as if thenewexpression were the$keysoperand itself.Using a variable works:
array_fill_keys([$o], 1)reaches the correctError.Repro
array_fill_keys([new stdClass()], 1)Error(object to string)array_fill_keys([$o], 1)ErrorError✓var_export([new stdClass()])alone is fine — bug is call-site operand lowering, same family as #10093/#10775 inline literal gaps.php-src reference
ext/standard/array.c—php_array_fill_keysImplementation (PHP-in-PHP)
[new …]array literal is materialized as array operand beforearray_fill_keystype checkext/standard/VmArray.phpruntime path already correct once operand arrives as arrayDone when (php-src-strict)
Errormatching Zend messagearray_combine([new stdClass()], [1])(already correct)Verification
Related: #10093, #10775, #8779, #1492