Skip to content

Stdlib: ArrayObject::__construct() missing — parent::__construct and new ArrayObject($array) fatal (ext/spl/spl_array.c) #10169

Description

@PurHur

Category

stdlib · php-src-strict

Problem

class_exists('ArrayObject') is true, but ArrayObject::__construct() is not registered (method_exists('ArrayObject', '__construct') → false). Subclasses calling parent::__construct([...]) fatal; new ArrayObject($array) cannot initialize storage. Countable::count() on instances also fails (Call to undefined method ArrayObject::count()).

Umbrella #3330 tracks full SPL parity; this issue is the minimal constructor + count slice workers can land first.

php-src reference

Repro (failure today — verified 2026-06-19)

<?php
declare(strict_types=1);
// Direct construct
$o = new ArrayObject([1, 2]);
echo count($o), "\n";

// Subclass parent::__construct
$anon = new class extends ArrayObject {
    public function __construct() { parent::__construct([1, 2]); }
};
echo count($anon), "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_export(method_exists(\"ArrayObject\",\"__construct\")); echo PHP_EOL;"
php bin/vm.php repro.php 2>&1 | head -5
php repro.php
'
Check Zend PHP 8.x VM today
method_exists('ArrayObject','__construct') true false ❌
count(new ArrayObject([1,2])) 2 fatal ❌
Anonymous extends ArrayObject + parent::__construct 2 Call to undefined static method arrayobject::__construct() ❌

Scope (this repo)

Layer Path
Builtin class ext/spl/BuiltinClasses.php, VmArrayObject.php (new)
VM Wrap internal array zval / HashTable — reuse lib/VM/HashTable.php
Registry ext/spl/Module.php or shared SPL loader (#3330)
JIT/AOT defer v1; document VM-only in capability matrix

PHP-in-PHP first: no C object layout in runtime/.

Done when

  • new ArrayObject([1, 2]) + count() returns 2 on bin/vm.php
  • Subclass parent::__construct($array) works
  • test/compliance/cases/stdlib/arrayobject_construct.phpt green
  • ./script/ci-fast.sh --filter arrayobject_construct green

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 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