Category
stdlib
Problem
Zend coerces str_repeat() argument #2 ($times) from float or numeric string to int. Negative values throw ValueError. This compiler requires a native integer type and throws LogicException before Zend-compatible coercion runs.
php-src reference
Repro
<?php
echo str_repeat('x', 2.9) . "\n"; // Zend: xx
try {
str_repeat('x', -1);
} catch (ValueError $e) {
echo get_class($e) . ': ' . $e->getMessage() . "\n";
}
./script/docker-exec.sh -- bash -lc '
source script/php-env.sh
php test/repro-maintainer/str_repeat_numeric_multiplier.php
php bin/vm.php test/repro-maintainer/str_repeat_numeric_multiplier.php
'
| Mode |
2.9 |
-1 |
| Zend |
xx |
ValueError |
| VM today |
LogicException |
ValueError (OK) but float path blocked |
Scope
| Area |
Files |
| VM |
ext/standard/str_repeat.php, ext/standard/VmString.php |
| JIT/AOT |
ext/standard/str_repeat.php, ext/standard/JitStrRepeat.php |
| Tests |
test/compliance/cases/stdlib/str_repeat_numeric_multiplier.phpt |
Done when
Category
stdlibProblem
Zend coerces
str_repeat()argument #2 ($times) from float or numeric string toint. Negative values throwValueError. This compiler requires a native integer type and throwsLogicExceptionbefore Zend-compatible coercion runs.php-src reference
ext/standard/string.c—PHP_FUNCTION(str_repeat)validates/coerces$timesvia_zend_parse_arg_long()Repro
2.9-1xxValueErrorLogicExceptionValueError(OK) but float path blockedScope
ext/standard/str_repeat.php,ext/standard/VmString.phpext/standard/str_repeat.php,ext/standard/JitStrRepeat.phptest/compliance/cases/stdlib/str_repeat_numeric_multiplier.phptDone when
$timescoerces to int on VM, JIT, and AOT$timesstill throwsValueErrorwith Zend message familystr_repeatPHPTs still pass