Category
stdlib · php-src-strict
Problem
PHP 8+ string-typed compare builtins must TypeError when operands are null, bool, or other non-string scalars — not silently coerce (e.g. strnatcmp(null,'1') → -1). This compiler returns comparison integers instead of failing.
Related but narrower: #4346 (array/object operands on strcmp family), #8825 (enum case operands).
php-src reference
Repro (failure today)
test/repro/maintainer_gap_string_compare_null_scalar.php:
php test/repro/maintainer_gap_string_compare_null_scalar.php # all TypeError
php bin/vm.php test/repro/maintainer_gap_string_compare_null_scalar.php # uncaught / returns int
| Call |
Zend |
VM today |
strnatcmp(null,'1') |
TypeError |
returns -1 ❌ |
strcoll(null,'a') |
TypeError |
returns -97 ❌ |
strncmp(null,'a',1) |
TypeError |
returns 0 ❌ |
version_compare(null,'1.0') |
TypeError |
returns -1 ❌ |
strcmp(true,'1') |
TypeError |
returns 0 ❌ |
Scope (this repo)
| Path |
Work |
ext/standard/ compare builtins |
Reuse VmString::coerceStringBuiltinArg / shared string-arg guards |
lib/JIT/ |
Same TypeError shapes when lowered |
PHP-in-PHP: guards in PHP builtins; shrink any C-only coercion.
Done when
Category
stdlib· php-src-strictProblem
PHP 8+ string-typed compare builtins must
TypeErrorwhen operands are null, bool, or other non-string scalars — not silently coerce (e.g.strnatcmp(null,'1')→-1). This compiler returns comparison integers instead of failing.Related but narrower: #4346 (array/object operands on
strcmpfamily), #8825 (enum case operands).php-src reference
ext/standard/string.c—PHP_FUNCTION(strnatcmp),strcoll,strncmp, …ext/standard/versioning.c—PHP_FUNCTION(version_compare)Repro (failure today)
test/repro/maintainer_gap_string_compare_null_scalar.php:strnatcmp(null,'1')TypeError-1❌strcoll(null,'a')TypeError-97❌strncmp(null,'a',1)TypeError0❌version_compare(null,'1.0')TypeError-1❌strcmp(true,'1')TypeError0❌Scope (this repo)
ext/standard/compare builtinsVmString::coerceStringBuiltinArg/ shared string-arg guardslib/JIT/PHP-in-PHP: guards in PHP builtins; shrink any C-only coercion.
Done when
TypeErrorfor every case on VM