Skip to content

ReflectionClass of ArrayObject, SplObjectStorage and DateTimeImmutable throws "does not exist", and Exception lists internal properties instead of php's #295

Closed

Description

@blacktrs

Summary

ReflectionClass of ArrayObject, SplObjectStorage and DateTimeImmutable throws "does not exist", and Exception lists internal properties instead of php's.

Repro

<?php
foreach (['ArrayObject', 'SplObjectStorage', 'DateTimeImmutable'] as $c) {
    echo $c, ': ', (new ReflectionClass($c))->getName(), "\n";
}
$names = array_map(fn($p) => $p->getName(), (new ReflectionClass('Exception'))->getProperties());
echo implode(',', $names), "\n";

Expected (php)

ArrayObject: ArrayObject
SplObjectStorage: SplObjectStorage
DateTimeImmutable: DateTimeImmutable
message,string,code,file,line,trace,previous

Actual (manticore 280d4d3b, Darwin arm64)

ArrayObject: 
[exit code 255]
PHP Fatal error:  Uncaught ReflectionException: Class "ArrayObject" does not exist

Tracking

Known-bug repro: tests/aot/repro/wrong/refl_prelude_classes_not_reflectable.php — bash tests/aot/xfail.sh -k refl_prelude_classes_not_reflectable reports XFAIL while this is open and XPASS once it is fixed; then move the repro into tests/aot/cases/ and close this issue.

Activity

  1. blacktrs commented on Oct 16, 2026

    @blacktrs
    ContributorAuthor

    Impact

    Found while fixing the symfony-app dev boot (#287–#290, merged in #294). Symfony\Polyfill\DeepClone::getHydrator() takes its "internal class" branch for prelude classes (ReflectionClass::isInternal() is true) and sets properties through ReflectionProperty::setValue(...). A deepclone_to_array / deepclone_from_array round-trip of an object graph that holds new ArrayObject([1]) or new DateTimeImmutable(...) still fails natively with Uncaught ReflectionException: Cannot write property ts; Zend round-trips it. A RuntimeException with a previous exception round-trips.

    State

    • ReflectionClass('ArrayObject' | 'SplObjectStorage' | 'DateTimeImmutable') throws Class "…" does not exist (these prelude classes carry no reflection table).
    • The prelude Exception reports traceNames / traceLines (internal fields) and no string property; php reports message, string, code, file, line, trace, previous. Since ReflectionProperty::setValue() on a property of a prelude class (Exception::$message, ::$code) throws "Cannot write property" #289 the real properties have accessors, so setValue() works on them.
    • The prelude ArrayObject::__construct declares only $array; php has $array, $flags, $iteratorClass (so (string)$param of internal constructors differs too: quoting '' vs "", NULL vs null, hints mixed vs object|array).

    Direction

    Emit reflection tables (properties with accessors, methods, parameters) for the prelude classes frameworks introspect, keep implementation-only fields out of getProperties(), and make the prelude signatures match php's arity.

  2. added
    bug
    wrong-answer
    on Oct 16, 2026
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

    bugwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions