Skip to content

Stdlib: print_r() and register var_dump() — debug output (ext/standard parity) #3133

Closed

Description

@PurHur

Category

stdlib

Problem

Debug output builtins are incomplete: print_r() is missing entirely; var_dump() exists in ext/standard/var_dump.php but is not registered in Module.php and only formats a tiny type subset.

Verified May 2026:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "print_r([1]);"'
# Call to undefined function print_r()

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "var_dump([1]);"'
# Call to undefined function var_dump()  (not registered)

php-src reference

Repro

<?php
$a = ['k' => 1, 'nested' => ['x' => 2]];
print_r($a, true);
var_dump($a);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
php repro.php
Runtime Result
Zend structured array output; var_dump includes types/lengths
VM undefined function for both

Scope (this repo)

Module Path
Register ext/standard/Module.php — add var_dump_() (already exists) and new print_r
Implement ext/standard/print_r.php (new)
Extend ext/standard/var_dump.php — arrays, objects (public props), recursion guard
Tests test/compliance/cases/stdlib/print_r.phpt, var_dump.phpt
Matrix php script/capability-matrix.php

JIT/AOT may remain VM-only v1; document in matrix notes.

Done when

Related

Activity

  1. added
    enhancementNew feature or request
    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 May 29, 2026
  2. PurHur commented on Jun 1, 2026

    @PurHur
    OwnerAuthor

    claim: worker-lane-b — starting this run

  3. PurHur commented on Jun 1, 2026

    @PurHur
    OwnerAuthor

    Merged via #3966

    Verification
    ```bash
    ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter "print_r|var_dump"'

    OK (2 tests, 2 assertions)

    ```

    • print_r() VM builtin with array/object formatting and return-string mode
    • var_dump() already registered; compliance PHPT added
    • JIT skipped until LLVM lowering
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 machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions