Category
bug · php-src-strict · phantom $mode · pillar 4 (sibling #28202 StringTrimMode enum; re-#23224)
Problem
Under PHP_COMPILER_PROFILE=8.4, trim(" x ", " ", true) throws TypeError: trim(): Argument #3 ($mode) must be of type StringTrimMode, bool given — proving a phantom 3rd $mode parameter wired to the non-existent StringTrimMode enum (#28202).
Zend/php-src arity is 2 (string $string, string $characters = " \n\r\t\v\0"); excess args are ArgumentCountError: trim() expects at most 2 arguments, 3 given. Same for ltrim / rtrim.
Verified 2026-08-06 vs php:8.4-cli (8.4.24).
| Repro |
Zend 8.4 |
VM PROFILE=8.4 |
trim(" x ", " ", true) |
ArgumentCountError: … at most 2 arguments, 3 given |
TypeError: … Argument #3 ($mode) must be of type StringTrimMode, bool given |
enum_exists('StringTrimMode') |
false |
true (#28202) |
Removing the phantom enum (#28202) should naturally restore arity-2 ArgumentCountError; this ticket tracks the call-site observable until that lands (or an explicit arity guard).
php-src reference
PHP implementation target
Repro
./script/docker-exec.sh -- bash -lc 'export PHP_COMPILER_PROFILE=8.4
php -r '"'"'file_put_contents("/tmp/t.php", "<?php\ntry { trim(\" x \", \" \", true); } catch (Throwable \$e) { echo get_class(\$e), \":\", \$e->getMessage(), PHP_EOL; }\necho \"enum=\", enum_exists(\"StringTrimMode\") ? \"1\" : \"0\", PHP_EOL;\n");'"'"'
php bin/vm.php /tmp/t.php'
Done when
Category
bug· php-src-strict · phantom$mode· pillar 4 (sibling #28202 StringTrimMode enum; re-#23224)Problem
Under
PHP_COMPILER_PROFILE=8.4,trim(" x ", " ", true)throwsTypeError: trim(): Argument #3 ($mode) must be of type StringTrimMode, bool given— proving a phantom 3rd$modeparameter wired to the non-existentStringTrimModeenum (#28202).Zend/php-src arity is 2 (
string $string, string $characters = " \n\r\t\v\0"); excess args areArgumentCountError: trim() expects at most 2 arguments, 3 given. Same forltrim/rtrim.Verified 2026-08-06 vs
php:8.4-cli(8.4.24).trim(" x ", " ", true)ArgumentCountError: … at most 2 arguments, 3 givenTypeError: … Argument #3 ($mode) must be of type StringTrimMode, bool givenenum_exists('StringTrimMode')falsetrue(#28202)Removing the phantom enum (#28202) should naturally restore arity-2
ArgumentCountError; this ticket tracks the call-site observable until that lands (or an explicit arity guard).php-src reference
ext/standard/string.stub.php—trim/ltrim/rtrim(2 params, no mode)ext/standard/string.c—php_trimPHP implementation target
ext/standard/— drop$mode/StringTrimModefrom trim family stubs + VM handlers (coordinate with Regression: StringTrimMode phantom on PROFILE≥8.4 — absent from php-src (re-#7283, ext/standard/string.stub.php) #28202)ArgumentCountErrorlike ZendRepro
Done when
trim/ltrim/rtrimreject 3rd positional arg with Zend-shapedArgumentCountErrorStringTrimModeparameter type in Reflection or TypeError path