Skip to content

Stdlib: fputcsv() fields array with enum case must Error like Zend (ext/standard/file.c) #5898

Description

@PurHur

Category

stdlib

Problem

fputcsv($handle, [E::A]) must throw Error: Object of class E could not be converted to string (php-src). VM either throws LogicException when the return is used, or silently skips the call when the return is discarded (#5896).

php-src reference

Repro (add test/repro-maintainer/parity_fputcsv_enum_field.php)

<?php
enum E: string { case A = 'a'; }
$fp = fopen('php://memory', 'r+');
try {
    $n = fputcsv($fp, [E::A]);
    rewind($fp);
    echo "n=$n line=", stream_get_contents($fp);
} catch (Throwable $e) {
    echo get_class($e), ': ', $e->getMessage(), PHP_EOL;
}
fclose($fp);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php8.2 test/repro-maintainer/parity_fputcsv_enum_field.php
php bin/vm.php test/repro-maintainer/parity_fputcsv_enum_field.php'
Engine Behavior
Zend Error on enum object in fields
VM LogicException when $n = … assigned; no throw for bare fputcsv(...) statement (#5896)

Scope

  • ext/standard/fputcsv.php — detect TYPE_ENUM_CASE in fields loop; throw Error with Zend message (not LogicException)
  • ext/standard/VmFs.php — keep PHP path; no new runtime/*.c
  • JIT: JitFputcsv.php when enum fields can reach native lowering

php-src-strict

Enum case objects are not strings; do not coerce backing scalar.

Done when

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 4, 2026
  2. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Runtime → PHP — starting this run (#5898: fputcsv enum field Error parity).

  3. PurHur commented on Jun 11, 2026

    @PurHur
    OwnerAuthor

    Unclaiming: fputcsv() enum field Error already green on master (VM + void context via BuiltinExecute::writeReturn). Zend and bin/vm.php both print Error: Object of class E could not be converted to string. Recommend closing as duplicate unless repro differs.

  4. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    unclaim: stale claim (>7 days, no open PR). Returning to implementation-ready queue for workers (maintainer sweep 2026-07-19).

  5. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    unclaim: stale claim (>7 days, no PR). Returning to queue for workers.

  6. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    unclaim: stale — last claim: was 2026-06-11 with no open PR and no further activity. Returning to implementation-ready queue for workers.

  7. PurHur commented on Jul 19, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #21174, #21179, #5898)

    Sequential PRs: str_getcsv escape E_DEPRECATED → fgetcsv/fputcsv escape E_DEPRECATED → fputcsv enum field Error. Merge each before the next.

  8. PurHur commented on Jul 20, 2026

    @PurHur
    OwnerAuthor

    merged: #21206

    Verification: VM+JIT already throw Zend Error for enum fields (assign + void) via VmFputcsv::coerceFieldCell. Added repro + compliance PHPT; VMTest OK (2).

    Batch complete: #21174, #21179, #5898 all merged.

  9. PurHur commented on Jul 20, 2026

    @PurHur
    OwnerAuthor

    Status check (stdlib worker)

    Repro already matches Zend on current master (VM + void context):

    Error: Object of class E could not be converted to string
    void:Error: Object of class E could not be converted to string
    

    Closing as already fixed (prior unclaim noted same). Batch #21174/#21179 complete; moving to #20635 null→TypeError string cluster.

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