Skip to content

isset($o[1][2]) on a nested ArrayAccess skips the outer offsetExists() call that php makes first. #606

Open

Description

@blacktrs

Summary

isset($o[1][2]) on a nested ArrayAccess skips the outer offsetExists() call that php makes first.

Repro

<?php
class Inner implements ArrayAccess {
    public function offsetExists(mixed $o): bool { echo "Inner::exists\n"; return true; }
    public function offsetGet(mixed $o): mixed { return 'v'; }
    public function offsetSet(mixed $o, mixed $v): void {}
    public function offsetUnset(mixed $o): void {}
}
class Outer implements ArrayAccess {
    public Inner $in;
    public function __construct() { $this->in = new Inner; }
    public function offsetExists(mixed $o): bool { echo "Outer::exists\n"; return true; }
    public function offsetGet(mixed $o): mixed { echo "Outer::get\n"; return $this->in; }
    public function offsetSet(mixed $o, mixed $v): void {}
    public function offsetUnset(mixed $o): void {}
}
$n = new Outer;
var_dump(isset($n[1][2]));

Expected (php)

Outer::exists
Outer::get
Inner::exists
bool(true)

Actual (manticore 527234a9, Darwin arm64)

Outer::get
Inner::exists
bool(true)

Tracking

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

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