Skip to content

Stdlib: mb_str_pad() — multibyte string padding (ext/mbstring/mbstring.c parity) #4006

Description

@PurHur

Category

stdlib · php-src-strict · spec refresh 2026-06-19

Problem

mb_str_pad() (PHP 8.3+) pads a multibyte string to a target display width. VM landed via #6081 (ext/mbstring/mb_str_pad.php, VmMbstring::mb_str_pad()), but this tracker stays open for remaining Zend gaps:

  1. JIT/AOTJitMbStrPad.php still uses in-module LLVM width logic instead of PHP SSOT (see php-in-php: ext/bcmath AOT lowering — share VmBcmath PHP path, unblock native self-host (ext/bcmath) #6100-style audit)
  2. Enum/object operands — must TypeError under php-src-strict (mirror mb_strlen guards)
  3. Capability matrix — ensure docs/capabilities.md notes JIT PHPT when green

Bundled duplicate: #6081 also tracks grapheme_strimwidth() (#9793); this issue is the mb_str_pad-only slice.

php-src reference

Repro (VM OK; enum gap)

<?php
var_dump(function_exists('mb_str_pad')); // true on VM (2026-06-19)
echo mb_str_pad('', 4, 'x'), "\n";   // あxxx

enum E: string { case A = 'a'; }
try {
    mb_str_pad(E::A, 5);
    echo "enum FAIL\n";
} catch (Throwable $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php test/repro/maintainer_mb_str_pad.php
php bin/jit.php test/repro/maintainer_mb_str_pad.php
'

Scope

Path Work
ext/mbstring/mb_str_pad.php ✅ VM builtin landed
ext/mbstring/VmMbstring.php Enum TypeError guards
ext/mbstring/JitMbStrPad.php Route through PHP helper or document VM-only
test/compliance/cases/stdlib/mb_str_pad*.phpt STR_PAD_* + enum operand

Done when

  • Enum case operand repro throws TypeError on VM/JIT/AOT (php-src-strict)
  • JIT repro matches VM for width/STR_PAD_* table
  • ./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter mb_str_pad' green
  • php script/capability-matrix.php reflects JIT/AOT notes

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