<?php
error_reporting(E_ALL);
foreach (['trim', 'str_contains', 'htmlspecialchars', 'strlen', 'explode'] as $f) {
try {
$r = match ($f) {
'str_contains' => str_contains(null, 'x'),
'explode' => explode(',', null),
'strlen' => strlen(null),
default => $f(null),
};
echo "$f => ";
var_export($r);
echo "\n";
} catch (Throwable $e) {
echo "$f EX ", get_class($e), ':', $e->getMessage(), "\n";
}
}
Category
Stdlib· php-src-strict · PROFILE≥8.4 · sibling of #28686 (mbstring)Problem
Under
PHP_COMPILER_PROFILE=8.4, classicext/standardstring APIs still coercenullto""(withE_DEPRECATED) instead of throwingTypeErrorlike Zend/php-src 8.4 stubs (stringnot?string).Verified 2026-08-07 on master
@45744edb07(VM + JIT) inside./script/docker-exec.sh. Host reference engine is 8.2 (deprecate+coerce); done-when is php-src 8.4 TypeError.str_contains(null, 'x')TypeErrorfalsestr_starts_with(null, 'x')/str_ends_with(null, 'x')TypeErrortrim/ltrim/rtrim(null)TypeError''strtolower/strtoupper/ucfirst/lcfirst/ucwords(null)TypeError''str_pad(null, n)/str_repeat(null, n)/strrev(null)TypeErrorstrlen(null)TypeError0addslashes/stripslashes/htmlspecialchars/htmlentities/nl2br/wordwrap(null)TypeError''explode(',', null)TypeError['']php-src reference
ext/standard/string.stub.php—stringparameters (not nullable) on listed APIsext/standard/string.c— ZPPstringrejection of null since 8.1 deprecation → 8.4 TypeErrorPHP implementation target
ext/standard+ VM/JIT (VmString::coerceStringBuiltinArg/JitStringBuiltinArg/TypeCheck) — not new C inruntime/Repro
Done when
TypeErroronnull(VM + JIT; AOT if in scope) matching Zend 8.4.phptundertest/compliance/cases/stdlib/(or string/) asserting TypeError