You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The optional fifth parameter $case_insensitive of substr_compare() is typed bool in php-src. Passing null must throw TypeError. VM/JIT call Variable::toBool() / JIT bool coercion and continue, returning a comparison result (0 in the probe).
This is distinct from haystack/needle soft-null on PROFILE≥8.4 (#21515, closed) — here all string/int operands are valid; only the bool argument is null.
Probed 2026-08-10 in php-compiler:22.04-dev (Zend 8.2.32, also verified under PHP_COMPILER_PROFILE=8.4).
Repro
Zend 8.2 / 8.4
VM/JIT (2026-08-10)
substr_compare('abc','ab',0,2,null)
TypeError: … $case_insensitive must be of type bool, null given
lib/JIT/Builtin/StringSubstrCompare.php / SubstrCompareJitHelper.php — emit TypeErrorRaise for non-bool $case_insensitive; remove LogicException “must be boolean in this compiler build” shortcut for boxed values
Category
Regression· php-src-strict · bool param strictness · pillar 4Problem
The optional fifth parameter
$case_insensitiveofsubstr_compare()is typedboolin php-src. Passingnullmust throwTypeError. VM/JIT callVariable::toBool()/ JIT bool coercion and continue, returning a comparison result (0in the probe).This is distinct from haystack/needle soft-null on PROFILE≥8.4 (#21515, closed) — here all string/int operands are valid; only the bool argument is null.
Probed 2026-08-10 in
php-compiler:22.04-dev(Zend 8.2.32, also verified underPHP_COMPILER_PROFILE=8.4).substr_compare('abc','ab',0,2,null)TypeError: … $case_insensitive must be of type bool, null givenint(0)(silent coerce) ❌php-src reference
ext/standard/string.c—Z_PARAM_BOOL/php_substr_compare$case_insensitivePHP implementation target
ext/standard/substr_compare.php— replace$ci->toBool()with strict bool check (mirrorrequireIntArgpattern for arg Stdlib: floatval, boolval, gettype(null) and expanded PHPT specs #5)lib/JIT/Builtin/StringSubstrCompare.php/SubstrCompareJitHelper.php— emitTypeErrorRaisefor non-bool$case_insensitive; removeLogicException“must be boolean in this compiler build” shortcut for boxed valuesRepro
Done when
TypeErroras Zend fornull/non-bool$case_insensitive.phptguard undertest/compliance/cases/stdlib/