Skip to content

Regression: ext/standard string builtins (null) coerce — Zend TypeError under PROFILE=8.4 (ext/standard/string.stub.php) #28689

Description

@PurHur

Category

Stdlib · php-src-strict · PROFILE≥8.4 · sibling of #28686 (mbstring)

Problem

Under PHP_COMPILER_PROFILE=8.4, classic ext/standard string APIs still coerce null to "" (with E_DEPRECATED) instead of throwing TypeError like Zend/php-src 8.4 stubs (string not ?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.

Call Zend 8.4+ VM/JIT PROFILE=8.4 (2026-08-07)
str_contains(null, 'x') TypeError Deprecated + false
str_starts_with(null, 'x') / str_ends_with(null, 'x') TypeError Deprecated + coerce
trim/ltrim/rtrim(null) TypeError Deprecated + ''
strtolower/strtoupper/ucfirst/lcfirst/ucwords(null) TypeError Deprecated + ''
str_pad(null, n) / str_repeat(null, n) / strrev(null) TypeError Deprecated + coerce
strlen(null) TypeError Deprecated + 0
addslashes/stripslashes/htmlspecialchars/htmlentities/nl2br/wordwrap(null) TypeError Deprecated + ''
explode(',', null) TypeError Deprecated + ['']

php-src reference

PHP implementation target

Repro

./script/docker-exec.sh -- bash -lc 'PHP_COMPILER_PROFILE=8.4 php bin/vm.php /tmp/std_string_null84.php'
# also: PHP_COMPILER_PROFILE=8.4 php bin/jit.php /tmp/std_string_null84.php
<?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";
    }
}

Done when

  • Under PROFILE≥8.4, listed string APIs throw TypeError on null (VM + JIT; AOT if in scope) matching Zend 8.4
  • Default/≤8.3 profile keeps Zend-compatible deprecate-or-coerce where php-src still does
  • Compliance .phpt under test/compliance/cases/stdlib/ (or string/) asserting TypeError
  • php-src-strict; no php-compiler-strict shortcut

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 machinebugSomething isn't workingimplementation-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