Skip to content

Stdlib: stream_get_meta_data / stream_set_blocking — stream introspection (ext/standard/streams.c parity) #3237

Closed

Description

@PurHur

Category

stdlib

Problem

fopen / fread / stream_context_create exist, but callers cannot introspect or configure open streams:

  • stream_get_meta_data($fp) — uri, mode, timed_out, blocked, etc.
  • stream_set_blocking($fp, bool) — toggle blocking I/O

HTTP clients, subprocess pipes (#3131), and socket code (#3202) depend on these.

php-src reference

  • ext/standard/streams.c — php_stream_get_meta_data, php_stream_set_blocking
  • main/streams/streams.c — php_stream metadata fields
  • ext/standard/basic_functions.c — registration

Repro (today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php bin/vm.php -r "var_dump(function_exists(\"stream_get_meta_data\"));"
php bin/vm.php -r "\$f = fopen(\"php://memory\", \"r+\"); var_dump(stream_get_meta_data(\$f));"
'

Zend PHP: bool(true); array with stream_type, mode, uri, …
This compiler: undefined function / fatal on first line

Scope (this repo)

Layer Files Notes
VM ext/standard/stream_get_meta_data.php, stream_set_blocking.php, VmStream.php Map FILE* / memory streams to meta array
Module ext/standard/Module.php Register both
Resource existing fopen resource type Attach path/mode at open time
JIT defer VM-only v1
Tests test/compliance/cases/stream_get_meta_data.phpt php://memory, temp file

v1 keys (minimum): uri, mode, stream_type, wrapper_type, seekable, timed_out, blocked, eof.

Done when

  • stream_get_meta_data(fopen('php://memory','r+')) returns expected keys on VM
  • stream_set_blocking toggles blocked key (best-effort on files)
  • Invalid resource: warning + false
  • ./script/ci-fast.sh --filter stream_get_meta green

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter stream_get_meta'

Dependencies

Links

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 May 29, 2026
  2. PurHur commented on Jun 5, 2026

    @PurHur
    OwnerAuthor

    Duplicate of #6007 (same stream_get_meta_data/stream_set_blocking scope, newer spec with repro path). Closing to reduce queue noise.

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