Skip to content

isset($o->$name) and $o->$name on an erased receiver ignore visibility: a private property reads as set from outside its class. #587

Closed

Description

@blacktrs

Summary

isset($o->$name) and $o->$name on an erased receiver ignore visibility: a private property reads as set from outside its class.

Repro

<?php
class Pg { private int $n = 1; protected int $q = 2; public int $pub = 5; }
function g(mixed $o, mixed $i) { return isset($o->$i) ? 'set' : 'no'; }
echo g(new Pg, 'pub'), g(new Pg, 'n'), g(new Pg, 'q'), "\n";
function r(mixed $o, mixed $i) { try { return $o->$i; } catch (Error $e) { return $e->getMessage(); } }
echo r(new Pg, 'pub'), ' ', r(new Pg, 'n'), ' ', r(new Pg, 'q'), "\n";

Expected (php)

setnono
5 Cannot access private property Pg::$n Cannot access protected property Pg::$q

Actual (manticore 670a19b4, Darwin arm64)

setsetset
5 1 2

Tracking

Known-bug repro: tests/aot/repro/wrong/dyn_prop_isset_private_from_outside.php — bash tests/aot/xfail.sh -k dyn_prop_isset_private_from_outside 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 Nov 7, 2026
  2. added a commit that references this issue on Nov 8, 2026
    d3089d0
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