Skip to content

Stdlib: array_is_list() parity (ext/standard/type.c) #9210

Description

@PurHur

Category

stdlib · php-src-strict

Problem

array_is_list() must match php-src zend_array_is_list() for key sequences and operand types. Audit (2026-06-18) confirms list-shape cases ([], [0,1], [1=>2], ['0'=>1], holes) already match Zend on VM. Remaining risk is operand typing and JIT lowering sharing the same VmArray::isList SSOT.

php-src reference

  • ext/standard/type.c — PHP_FUNCTION(array_is_list) → zend_array_is_list()
  • Zend/zend_hash.c — zend_array_is_list()
  • Stubs: ext/standard/basic_functions.stub.php

Repro

<?php
declare(strict_types=1);

// List shape (all must match Zend)
var_dump(array_is_list([]));              // true
var_dump(array_is_list([0 => 1, 1 => 2])); // true
var_dump(array_is_list([1 => 2]));         // false
var_dump(array_is_list(['0' => 1]));       // true (string key "0" is int 0)
var_dump(array_is_list([0 => 1, 2 => 3])); // false (hole at index 1)

// Operand types — must TypeError, not silent coerce
try {
    array_is_list(null);
} catch (TypeError $e) {
    echo "null: ", $e->getMessage(), "\n";
}

enum Color: string { case Red = 'red'; }
try {
    array_is_list(Color::Red);
} catch (TypeError $e) {
    echo "enum: ", $e->getMessage(), "\n";
}

Commands

php repro.php                                    # Zend reference
./script/docker-exec.sh php bin/vm.php repro.php
./script/docker-exec.sh php bin/jit.php repro.php  # if JitArrayIsList wired

Zend expected (operand errors):

  • array_is_list(): Argument #1 ($array) must be of type array, null given
  • array_is_list(): Argument #1 ($array) must be of type array, Color given

Scope (this repo)

  • ext/standard/array_is_list.php
  • ext/standard/VmArray.php — VmArray::isList() (SSOT)
  • lib/JIT/Builtin/JitArrayIsList.php (or equivalent) — must call same logic, not duplicate list walk in LLVM

Done when (php-src-strict)

  • VM repro output matches Zend for all list-shape and TypeError cases above.
  • JIT/AOT (if applicable) uses PHP SSOT via helper bridge — no second list-walk implementation.
  • Add test/compliance/cases/array_is_list_*.phpt or unit beside repro covering hole + null + enum operands.
  • Close only when VM and JIT paths green (or JIT explicitly documented VM-only with gap in docs/capabilities.md).

Notes

  • Do not treat ['0'=>1] as false — php-src treats key 0 as list-eligible (verified against Zend 8.2+).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions