Category
Regression · php-src-strict · ext/mbstring invalid ``
Problem
After #13377 fixed mb_strtoupper/mb_strtolower (and mb_strlen/mb_convert_case already match), several mbstring APIs still throw a compiler-private LogicException for an unknown encoding instead of Zend’s ValueError.
Call (Zend 8.2.32 / HEAD bf5802236, 2026-08-06) |
Zend |
VM / PROFILE=8.4 |
mb_substr('a',0,1,'nope') |
ValueError: … must be a valid encoding, \"nope\" given |
LogicException: mb_substr requires mbstring for encoding nope… |
mb_strpos('a','a',0,'nope') |
ValueError (arg #4) |
LogicException: mbstring search requires… |
mb_str_split('a',1,'nope') |
ValueError (arg #3) |
LogicException |
mb_strcut / mb_strimwidth / mb_strwidth |
ValueError |
LogicException |
mb_stripos / mb_strrpos / mb_strripos |
ValueError |
LogicException |
mb_strstr / mb_stristr / mb_strrchr / mb_strrichr |
ValueError |
LogicException |
mb_str_pad(..., 'nope') (PROFILE≥8.4) |
ValueError |
LogicException |
Already green (do not regress): mb_strlen, mb_strtoupper, mb_strtolower, mb_convert_case.
php-src reference
PHP implementation target
- Shared encoding-validation helper used by the listed builtins in
ext/mbstring/ (and JIT lowering if separate) — throw Zend-identical ValueError, not LogicException
- PHP-in-PHP only — no new
runtime/*.c
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/mb_enc_valueerror.php <<'"'"'PHP'"'"'
<?php
foreach ([
fn() => mb_substr(\"a\", 0, 1, \"nope\"),
fn() => mb_strpos(\"a\", \"a\", 0, \"nope\"),
fn() => mb_str_split(\"a\", 1, \"nope\"),
] as $i => $fn) {
try { $fn(); echo \"$i ok\n\"; }
catch (Throwable $e) { echo $i, \" \", get_class($e), \": \", $e->getMessage(), \"\n\"; }
}
PHP
php /tmp/mb_enc_valueerror.php
php bin/vm.php /tmp/mb_enc_valueerror.php'
Done when
Trust snapshot (this maintainer run)
bootstrap-inventory --check: OK 7075/7075
make north-star5-verify-fast: OK
make bootstrap-selfhost-helloworld: OK (Hello World)
Category
Regression· php-src-strict · ext/mbstring invalid ``Problem
After #13377 fixed
mb_strtoupper/mb_strtolower(andmb_strlen/mb_convert_casealready match), several mbstring APIs still throw a compiler-privateLogicExceptionfor an unknown encoding instead of Zend’sValueError.bf5802236, 2026-08-06)mb_substr('a',0,1,'nope')ValueError: … must be a valid encoding, \"nope\" givenLogicException: mb_substr requires mbstring for encoding nope…mb_strpos('a','a',0,'nope')ValueError(arg #4)LogicException: mbstring search requires…mb_str_split('a',1,'nope')ValueError(arg #3)LogicExceptionmb_strcut/mb_strimwidth/mb_strwidthValueErrorLogicExceptionmb_stripos/mb_strrpos/mb_strriposValueErrorLogicExceptionmb_strstr/mb_stristr/mb_strrchr/mb_strrichrValueErrorLogicExceptionmb_str_pad(..., 'nope')(PROFILE≥8.4)ValueErrorLogicExceptionAlready green (do not regress):
mb_strlen,mb_strtoupper,mb_strtolower,mb_convert_case.php-src reference
ext/mbstring/mbstring.c— encoding resolve →zend_argument_value_error/ ValueErrormb_strtoupper/mb_strtolower)PHP implementation target
ext/mbstring/(and JIT lowering if separate) — throw Zend-identicalValueError, notLogicExceptionruntime/*.cRepro
Done when
ValueError(message + arg index) on VM (and JIT when in scope)LogicException/ "in this compiler build" for invalid encodingstest/repro/guard covering at leastmb_substr+mb_strpos+mb_str_splitTrust snapshot (this maintainer run)
bootstrap-inventory --check: OK 7075/7075make north-star5-verify-fast: OKmake bootstrap-selfhost-helloworld: OK (Hello World)