Skip to content

Stdlib: array_fill_keys() nested array keys — Array-to-string warning + 'Array' key missing (ext/standard/array.c) #10848

Description

@PurHur

Summary

array_fill_keys() with a nested array as a key element must emit Zend's E_WARNING: Array to string conversion and use the string key "Array". VM throws Error: Object of class array could not be converted to string (wrong exception class/message).

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_array_fill_keys_array_key.php
php bin/vm.php test/repro/maintainer_gap_array_fill_keys_array_key.php'
Call Zend PHP 8.2 VM today
array_fill_keys([[[1]]], 1) warning + array('Array' => 1) Error

php-src reference

Implementation (PHP-in-PHP)

  • ext/standard/VmArray.php — array key coercion: warn via frame helper, use literal "Array" key (same as ext/standard/array_combine / php-src _array_to_string)
  • Do not route through object __toString path

Done when (php-src-strict)

  • Repro: warning + array('Array' => 1) on VM
  • Scalar keys unchanged

Verification

./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_array_fill_keys_array_key.php

Related: #8779, #1492

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions