Skip to content

Stdlib: str_getcsv() — enum case string operands must TypeError (ext/standard/string.c, php-src-strict) #8853

Description

@PurHur

Category

stdlib | php-src-strict

Problem

str_getcsv() accepts backed enum case operands for $string (and delimiter/enclosure/escape when enum) and silently coerces via backing string. Zend raises TypeError.

Observed 2026-06-15:

Engine str_getcsv(E::A) where case A = 'a,b'
Zend PHP 8.2+ TypeError
This compiler VM array('a','b') (coerced)

php-src reference

Repro

<?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\"; }"
'

Scope

  • ext/standard/str_getcsv.php — VmString::coerceStringBuiltinArg() on all string parameters
  • JIT: JitStringBuiltinArg mirrors
  • test/compliance/cases/stdlib/str_getcsv_enum_case_typeerror.phpt

Done when

  • Repro raises catchable TypeError on VM (php-src-strict)
  • JIT/AOT agree when in scope
  • ./script/ci-fast.sh --filter str_getcsv_enum green

Related

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions