<?php
enum E: string { case A = 'a,b'; }
try {
var_export(str_getcsv(E::A));
} catch (TypeError $e) {
echo 'TypeError: ', $e->getMessage(), "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php -r "enum E: string { case A = \"a,b\"; } try { str_getcsv(E::A); } catch (TypeError \$e) { echo \"TypeError\n\"; }"
php bin/vm.php -r "enum E: string { case A = \"a,b\"; } try { str_getcsv(E::A); } catch (TypeError \$e) { echo \"TypeError\n\"; }"
'
Category
stdlib| php-src-strictProblem
str_getcsv()accepts backed enum case operands for$string(and delimiter/enclosure/escape when enum) and silently coerces via backing string. Zend raisesTypeError.Observed 2026-06-15:
str_getcsv(E::A)wherecase A = 'a,b'TypeErrorarray('a','b')(coerced)php-src reference
ext/standard/string.c—php_str_getcsv(), string arg guardsexplode()enum TypeError — same coercion class)Repro
Scope
ext/standard/str_getcsv.php—VmString::coerceStringBuiltinArg()on all string parametersJitStringBuiltinArgmirrorstest/compliance/cases/stdlib/str_getcsv_enum_case_typeerror.phptDone when
TypeErroron VM (php-src-strict)./script/ci-fast.sh --filter str_getcsv_enumgreenRelated