Skip to content

A static method that replaces a by-reference array argument with an array of objects reads back as strings in the caller (a plain function does not). #485

Closed

Description

@blacktrs

Summary

A static method that replaces a by-reference array argument with an array of objects reads back as strings in the caller (a plain function does not).

Repro

<?php
final class L { public int $n = 1; }
final class C
{
    public static function put(array &$out): void
    {
        $o = [];
        $o[] = new L();
        $out = $o;
    }
}
function viaStatic(): void { $out = ['stale']; C::put($out); var_dump(gettype($out[0]), $out[0] instanceof L); }
viaStatic();

Expected (php)

string(6) "object"
bool(true)

Actual (manticore 0f035fc1, Darwin arm64)

string(6) "string"
bool(false)

Tracking

Known-bug repro: tests/aot/repro/wrong/static_method_byref_array_retype.php — bash tests/aot/xfail.sh -k static_method_byref_array_retype 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. added
    bug
    wrong-answer
    on Oct 26, 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