Category
stdlib · php-src-strict · null→int DEP · pillar 4
Problem
substr_compare($haystack, $needle, null) must emit E_DEPRECATED for passing null to int $offset, coerce to 0, and return the comparison result. VM/JIT throw TypeError: … Argument #3 ($offset) must be of type int, null given with no deprecation.
Probed 2026-08-09 @ dd181e4f49 vs container Zend 8.2.32. VM and JIT agree (both wrong).
| Repro |
Zend 8.2+ |
VM / JIT |
substr_compare('abc', 'b', null) |
DEP then -1 |
TypeError on $offset |
php-src reference
PHP implementation target
ext/standard substr_compare / shared int-arg null DEP+coerce helper (same pattern as siblings for strspn/strcspn/range null args)
- PHP-in-PHP; no new
runtime/*.c logic
Repro
./script/docker-exec.sh -- bash -lc 'cat > /tmp/substr_compare_null.php <<\"PHP\"
<?php
error_reporting(E_ALL);
set_error_handler(static function (int $no, string $str): bool {
echo \"WARN: $str\n\";
return true;
});
try {
var_export(substr_compare(\"abc\", \"b\", null));
echo \"\n\";
} catch (Throwable $e) {
echo get_class($e), \": \", $e->getMessage(), \"\n\";
}
PHP
php /tmp/substr_compare_null.php; php bin/vm.php /tmp/substr_compare_null.php; php bin/jit.php /tmp/substr_compare_null.php'
Done when
Category
stdlib· php-src-strict · null→int DEP · pillar 4Problem
substr_compare($haystack, $needle, null)must emitE_DEPRECATEDfor passing null toint $offset, coerce to0, and return the comparison result. VM/JIT throwTypeError: … Argument #3 ($offset) must be of type int, null givenwith no deprecation.Probed 2026-08-09 @
dd181e4f49vs container Zend 8.2.32. VM and JIT agree (both wrong).substr_compare('abc', 'b', null)-1TypeErroron $offsetphp-src reference
ext/standard/string.c—PHP_FUNCTION(substr_compare)ext/standard/string.stub.php—substr_compare(string $haystack, string $needle, int $offset, …)PHP implementation target
ext/standardsubstr_compare / shared int-arg null DEP+coerce helper (same pattern as siblings forstrspn/strcspn/rangenull args)runtime/*.clogicRepro
Done when
.phptundertest/compliance/cases/stdlib/