Skip to content

json_encode and get_object_vars show uninitialized typed properties, which php skips #115

Closed

Description

@blacktrs

Summary

json_encode and get_object_vars show uninitialized typed properties, which php skips.

Repro

<?php
class Typed { public int $set = 1; public int $unset; public ?int $nul; }
$t = new Typed();
echo json_encode($t), "\n";
var_dump(array_keys(get_object_vars($t)));

Expected (php)

{"set":1}
array(1) {
  [0]=>
  string(3) "set"
}

Actual (manticore e8b98faa, Darwin arm64)

{"set":1,"unset":0,"nul":null}
array(3) {
  [0]=>
  string(3) "set"
  [1]=>
  string(5) "unset"
  [2]=>
  string(3) "nul"
}

Tracking

Known-bug repro: tests/aot/repro/wrong/json_encode_uninitialized_typed_props.php — bash tests/aot/xfail.sh -k json_encode_uninitialized_typed_props 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 7, 2026
  2. added
    needs-design
    area:runtime
    on Oct 13, 2026
  3. blacktrs commented on Oct 13, 2026

    @blacktrs
    ContributorAuthor

    Scope: layout/ABI epic. The runtime has no 'uninitialized' state for typed properties (var_dump shows 0/NULL), so json_encode/get_object_vars cannot skip them. Needs an uninit sentinel in the property layout (MemoryAbi) + readers that throw 'must not be accessed before initialization'. Skipped in batch C.

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:runtimebugneeds-designwrong-answer

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions