Summary
When array_fill_keys() receives a resource in the keys list, Zend coerces it to the string "Resource id #N" (with E_WARNING in some builds) and builds the result hash. VM throws Error: Object of class Resource could not be converted to string instead.
Repro
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_array_fill_keys_resource.php
php bin/vm.php test/repro/maintainer_gap_array_fill_keys_resource.php'
| Call |
Zend PHP 8.2 |
VM today |
array_fill_keys([$stream], 1) |
array('Resource id #5' => 1) |
Error ❌ |
php-src reference
Implementation (PHP-in-PHP)
ext/standard/VmArray.php — array_fill_keys key coercion: resources → "Resource id #" + id (match VmResource / print_r formatting)
- Share helper with other builtins that accept hash keys (
array_combine already errors correctly on objects — only resource path differs)
- No new C runtime
Done when (php-src-strict)
Verification
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_array_fill_keys_resource.php
Related: #8779 (enum keys), #1492
Summary
When
array_fill_keys()receives a resource in the keys list, Zend coerces it to the string"Resource id #N"(withE_WARNINGin some builds) and builds the result hash. VM throwsError: Object of class Resource could not be converted to stringinstead.Repro
array_fill_keys([$stream], 1)array('Resource id #5' => 1)php-src reference
ext/standard/array.c—php_array_fill_keys,_array_to_string/ resource key coercion viaZVAL_LONGhash key pathImplementation (PHP-in-PHP)
ext/standard/VmArray.php—array_fill_keyskey coercion: resources →"Resource id #"+ id (matchVmResource/print_rformatting)array_combinealready errors correctly on objects — only resource path differs)Done when (php-src-strict)
array('Resource id #N' => 1)on VMError(not regressed)Verification
Related: #8779 (enum keys), #1492