Skip to content

Regression: strlen()/strtolower()/strtoupper()/strrev(null) — coerce on 8.4 forward profile not TypeError (re-#18599/#18190, ext/standard/string.c) #19276

Description

@PurHur

Category

stdlib · php-src-strict · PHP_COMPILER_PROFILE=8.4 forward null guards

Problem

Closed #18599 / #18780 / #18190 required null→TypeError for core case/length builtins. Under PHP_COMPILER_PROFILE=8.4, master again coerces null → "" / 0 (2026-07-15). Sibling phonetic pair is green after #19251; this batch still coerces.

Repro Zend 8.4 forward VM PROFILE=8.4 (2026-07-15)
strlen(null) TypeError 0
strtolower(null) / strtoupper(null) TypeError ''
strrev(null) TypeError ''

php-src reference

PHP implementation target

  • ext/standard/VmString.php — shared forward-profile null guard for case/length/rev batch
  • lib/JIT/Builtin/String* — VM/JIT/AOT agree

Repro

./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4
php -r '"'"'file_put_contents("/tmp/sl.php", "<?php
foreach ([\"strlen\",\"strtolower\",\"strtoupper\",\"strrev\"] as \$f) {
  try { var_export(\$f(null)); echo \" \$f:OK\\n\"; }
  catch (Throwable \$e) { echo \"\$f: \".get_class(\$e).\"\\n\"; }
}
");'"'"'
php bin/vm.php /tmp/sl.php'
# expect: *: TypeError · actual: *:OK coerced

Done when

  • All four builtins throw TypeError on null under PHP_COMPILER_PROFILE=8.4 (VM/JIT/AOT)
  • Compliance .phpt under test/compliance/cases/string/
  • php-src-strict; no php-compiler-strict coerce 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 workingenhancementNew 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