Category
stdlib
Problem
str_pad() and count_chars() in Zend throw TypeError when the primary string operand is not a string. This compiler raises LogicException with build-specific messages (str_pad() input must be a string…, count_chars() argument #1 must be a string…).
Pad-length numeric-string coercion is tracked in #4170; count_chars mode/return flags in #4204. This ticket is string operand type validation only.
php-src reference
Repro (failure today)
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro-maintainer/parity_str_pad_count_chars_type.php
php bin/vm.php test/repro-maintainer/parity_str_pad_count_chars_type.php
'
| Call |
Zend PHP 8.x |
This compiler VM |
str_pad([], 5) |
TypeError |
LogicException |
count_chars([]) |
TypeError |
LogicException |
Repro script: test/repro-maintainer/parity_str_pad_count_chars_type.php
Scope (this repo)
| Module |
Path |
| VM |
ext/standard/str_pad.php, ext/standard/count_chars.php |
| JIT |
corresponding JIT builtins in lib/JIT/Builtin/ |
| php-in-php |
no new runtime/*.c |
Done when
- VM/JIT/AOT throw
TypeError with Zend messages for non-string primary operands (str_pad, count_chars).
- Repro script: Zend and VM both throw
TypeError (not LogicException); exit non-zero with catchable error.
- Happy-path behavior unchanged; add or extend compliance under
test/compliance/cases/stdlib/ if missing.
Labels
stdlib, implementation-ready
Category
stdlibProblem
str_pad()andcount_chars()in Zend throwTypeErrorwhen the primary string operand is not a string. This compiler raisesLogicExceptionwith build-specific messages (str_pad() input must be a string…,count_chars() argument #1 must be a string…).Pad-length numeric-string coercion is tracked in #4170;
count_charsmode/return flags in #4204. This ticket is string operand type validation only.php-src reference
ext/standard/string.c—PHP_FUNCTION(str_pad),PHP_FUNCTION(count_chars)Repro (failure today)
str_pad([], 5)TypeErrorLogicExceptioncount_chars([])TypeErrorLogicExceptionRepro script:
test/repro-maintainer/parity_str_pad_count_chars_type.phpScope (this repo)
ext/standard/str_pad.php,ext/standard/count_chars.phplib/JIT/Builtin/runtime/*.cDone when
TypeErrorwith Zend messages for non-string primary operands (str_pad,count_chars).TypeError(notLogicException); exit non-zero with catchable error.test/compliance/cases/stdlib/if missing.Labels
stdlib,implementation-ready