Category
stdlib · php-src-strict
Problem
PHP 8.4 mb_trim(), mb_ltrim(), and mb_rtrim() accept named parameters characters: and encoding: per php-src stubs. Positional calls work; named characters: (and encoding:) throw LogicException: Too many arguments to function call instead of trimming.
Root cause: Internal builtin metadata does not expose php-src parameter names to lib/VM/NamedArgs.php, so named slots are treated as excess arguments.
php-src reference
Repro (failure today)
<?php
$s = '--héllo--';
var_dump(mb_trim($s, '-')); // OK: string(6) "héllo"
var_dump(mb_trim($s, characters: '-')); // FAIL: LogicException
Also in repo: test/repro/maintainer_gap_mb_trim_named_characters.php
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_mb_trim_named_characters.php'
Implementation hints (PHP-in-PHP)
- Register php-src parameter names on
mb_trim / mb_ltrim / mb_rtrim Internal builtins (same pattern as other named-arg-aware stdlib)
ext/mbstring/VmMbstring.php — runTrimBuiltin() already handles positional characters / encoding; wire named resolution before arg count check
- Mirror in
ext/mbstring/JitMbTrim.php for JIT/AOT when in scope
- No new C runtime
Scope
ext/mbstring/mb_trim.php, mb_ltrim.php, mb_rtrim.php
ext/mbstring/VmMbstring.php, JitMbTrim.php
lib/VM/NamedArgs.php (if shared Internal metadata fix)
Done when
Verification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_mb_trim_named_characters.php'
Category
stdlib· php-src-strictProblem
PHP 8.4
mb_trim(),mb_ltrim(), andmb_rtrim()accept named parameterscharacters:andencoding:per php-src stubs. Positional calls work; namedcharacters:(andencoding:) throwLogicException: Too many arguments to function callinstead of trimming.Root cause: Internal builtin metadata does not expose php-src parameter names to
lib/VM/NamedArgs.php, so named slots are treated as excess arguments.php-src reference
ext/mbstring/mbstring.stub.php—mb_trim(string $string, ?string $characters = null, ?string $encoding = null)ext/mbstring/mbstring.c—php_mb_trim/mb_trim_commonRepro (failure today)
Also in repo:
test/repro/maintainer_gap_mb_trim_named_characters.php./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_mb_trim_named_characters.php'Implementation hints (PHP-in-PHP)
mb_trim/mb_ltrim/mb_rtrimInternal builtins (same pattern as other named-arg-aware stdlib)ext/mbstring/VmMbstring.php—runTrimBuiltin()already handles positionalcharacters/encoding; wire named resolution before arg count checkext/mbstring/JitMbTrim.phpfor JIT/AOT when in scopeScope
ext/mbstring/mb_trim.php,mb_ltrim.php,mb_rtrim.phpext/mbstring/VmMbstring.php,JitMbTrim.phplib/VM/NamedArgs.php(if shared Internal metadata fix)Done when
mb_trim($s, characters: '-')returns trimmed string under VM (php-src-strict)encoding:named arg works;mb_ltrim/mb_rtrimagreeVerification
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php test/repro/maintainer_gap_mb_trim_named_characters.php'