<?php
declare(strict_types=1);
// test/repro-maintainer/numeric_string_int_params.php
$a = [10, 20, 30, 40];
var_export(array_splice($a, '1', '2'));
echo "\n";
echo substr_count('abababa', 'ab', '2', '4'), "\n";
var_export(array_change_key_case(['Foo' => 1], '0'));
echo "\n";
Category
stdlibProblem
Open #4176 tracks numeric-string coercion for
fread/substr/array_slice. Several other builtins with$offset/$length/ flag int parameters still require nativeintand throwLogicExceptionwhen callers pass numeric strings — unlike Zendzend_parse_parameterslong coercion.Affected today (VM + JIT):
array_splice()$offset,$lengthext/standard/array_splice.phpsubstr_count()$offset,$lengthext/standard/substr_count.phparray_change_key_case()$caseflagext/standard/array_change_key_case.phpphp-src reference
ext/standard/array.c—PHP_FUNCTION(array_splice),PHP_FUNCTION(array_change_key_case)ext/standard/string.c—PHP_FUNCTION(substr_count)Repro (failure today)
array_splice($a,'1','2')[20,30]LogicExceptionsubstr_count('abababa','ab','2','4')2LogicExceptionarray_change_key_case($a,'0')LogicExceptionScope (this repo)
JitLongArg/ plannedVmArg::coerceToInt()from #4176ext/standard/array_splice.php,substr_count.php,array_change_key_case.phpcall()pathstest/compliance/cases/stdlib/array_splice_numeric_string.phpt, etc.Done when
TypeErrorlike Zend (array_splice($a, 'abc'))./script/ci-fast.sh --filter "array_splice|substr_count|array_change_key_case"greenRelated
array_slice$preserve_keys— separate)