Skip to content

Language: var_export(include $file, true) remaps args — returns pid-like int not file return (re-#21938/#24372) #25851

Description

@PurHur

Category

bug · php-src-strict · language · include expression as FuncCall arg / two-arg remapping

Problem

var_export(include $path, true) (include nested as the first argument of a two-arg call) does not yield the included file’s return value. VM prints a pid-like integer (same as getmypid() used while building $path) and stringifies that for the second call. Assigning include to a local first, or single-arg wrappers like id(include $path) / strlen(include $path), match Zend.

Same family as closed #24372 (print_r($x, true) as call arg remaps the next literal) and closed #21938 (include/require expression returns).

Probed 2026-07-31 @ 3aa069e85 — Zend 8.2.32 vs php bin/vm.php.

Repro Zend 8.2.32 VM (2026-07-31)
var_export(include $path, true) where file return 7 '7' pid-like int / '<pid>'
$a = include $path; var_export($a, true) '7' '7' ✓
id(include $path) / strlen(include $path) OK OK ✓
print_r(include $path, true) (array return) OK OK ✓ (this shape)

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'cat > /tmp/ve_include.php <<'"'"'PHP'"'"'
<?php
$path = sys_get_temp_dir() . "/ve_" . getmypid() . ".php";
file_put_contents($path, "<?php return 7;\n");
echo var_export(include $path, true), "\n";
$a = include $path;
echo var_export($a, true), "\n";
@unlink($path);
PHP
php /tmp/ve_include.php
php bin/vm.php /tmp/ve_include.php'

Done when

  • var_export(include \$path, true) matches Zend for scalar/array file returns
  • Temp-assigned path still green; id(include) / strlen(include) unchanged
  • Compliance .phpt under test/compliance/cases/language/
  • php-src-strict; no php-compiler-strict shortcut

Activity

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:compilerCompiler / CFG / JITarea:vmVirtual machinebugSomething isn't workingimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-2:languagePhase 2 – language features

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions