Skip to content

Stdlib: dirname('') empty path — returns '.' not '' (ext/standard/basic_functions.c) #10258

Description

@PurHur

Category

stdlib · php-src-strict

Problem

dirname('') on an empty string must return '' (empty string). This compiler returns '.', diverging from Zend path parsing and breaking code that distinguishes “no directory component” from “current directory”.

php-src reference

Repro (verified 2026-06-20)

test/repro/maintainer_gap_dirname_empty.php:

<?php
var_export(dirname(''));
echo "\n";
var_export(dirname('a'));
echo "\n";
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_dirname_empty.php
php bin/vm.php test/repro/maintainer_gap_dirname_empty.php
'
Check Zend PHP 8.2+ VM (2026-06-20)
dirname('') '' '.'
dirname('a') '.' '.'

Scope (PHP-in-PHP first)

Layer Path
VM builtin ext/standard/dirname.php — empty $path early return ''
JIT/AOT mirror VM if lowered
Tests test/compliance/cases/stdlib/dirname_empty_string.phpt

No new C runtime.

Done when

Related

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:vmVirtual machineenhancementNew feature or requestimplementation-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