Category
stdlib · php-src-strict
Problem
realpath('') with an empty string path must resolve to the current working directory (same as realpath('.')). This compiler returns false, breaking path normalization in self-host and app code that passes user input through realpath() without an explicit . fallback.
php-src reference
Repro (verified 2026-06-20)
test/repro/maintainer_gap_realpath_empty.php:
<?php
var_export(realpath(''));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_realpath_empty.php
php bin/vm.php test/repro/maintainer_gap_realpath_empty.php
'
| Runtime |
Result |
| Zend PHP 8.2+ |
'/path/to/cwd' (non-empty string) |
php bin/vm.php |
false ❌ |
Scope (PHP-in-PHP first)
| Layer |
Path |
| VM builtin |
ext/standard/realpath.php — treat '' like '.' before stat/canonicalize |
| JIT/AOT |
mirror VM if realpath is lowered inline |
| Tests |
test/compliance/cases/stdlib/realpath_empty_string.phpt |
No new C runtime.
Done when
Related
Category
stdlib· php-src-strictProblem
realpath('')with an empty string path must resolve to the current working directory (same asrealpath('.')). This compiler returnsfalse, breaking path normalization in self-host and app code that passes user input throughrealpath()without an explicit.fallback.php-src reference
ext/standard/basic_functions.c—php_realpath()empty-path →VCWD_GETCWDthen canonicalizemain/php_streams.c— virtual cwd resolutionRepro (verified 2026-06-20)
test/repro/maintainer_gap_realpath_empty.php:'/path/to/cwd'(non-empty string)php bin/vm.phpfalse❌Scope (PHP-in-PHP first)
ext/standard/realpath.php— treat''like'.'before stat/canonicalizerealpathis lowered inlinetest/compliance/cases/stdlib/realpath_empty_string.phptNo new C runtime.
Done when
realpath('.')unchangedfalseper ZendRelated