Skip to content

Stdlib: var_dump()/print_r() show anonymous class internal name (NUL+filename suffix) #17444

Closed

Description

@PurHur

Repro (Zend PHP 8.2)

<?php
$o = new class {};
var_dump($o);
print_r($o);

Zend output contains:

  • object(class@anonymous)#...
  • class@anonymous Object

Repro (php-compiler VM)

php bin/vm.php -r '$o=new class{}; var_dump($o); print_r($o);'

Observed output contains the internal anonymous class name:

  • class@anonymous\0Command line code:1$0

Expected

Match Zend formatting for anonymous classes in debug output (strip the internal \0... suffix).

Reference (php-src)

  • ext/standard/var.c (php_var_dump, php_print_r)

Done when

  • VM output matches Zend for the snippet above.
  • Add a regression test under test/compliance/ or test/repro/ covering var_dump + print_r on anonymous classes.

Activity

  1. added
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 8, 2026
  2. PurHur commented on Jul 8, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  3. PurHur commented on Jul 8, 2026

    @PurHur
    OwnerAuthor

    Merged via #17448.

    Fix: VmVarDump and VmPrintR now call VmObjectDebugType::fromClassName() (same SSOT as #17443 get_debug_type()) so anonymous classes display as class@anonymous without the internal NUL+filename suffix.

    Verification:

    • php bin/vm.php test/repro/maintainer_gap_var_dump_print_r_anonymous_class.php → ok
    • ./script/phpunit.sh --filter 'VMTest::testCases.*var_dump_print_r_anonymous' → OK
    • AOT compile: php -d memory_limit=4G bin/compile.php -o build/test-var-dump-print-r-anon-aot test/fixtures/aot/compile-only/var_dump_print_r_anonymous_class.php → exit 0
  4. PurHur commented on Jul 8, 2026

    @PurHur
    OwnerAuthor

    claim: cursor-agent-lane-a — starting this run

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:vmVirtual machineimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions