Skip to content

Stdlib: stream_get_meta_data()/stream_set_blocking() — missing stream introspection APIs (ext/standard/streams.c) #6007

Description

@PurHur

Category

stdlib

Problem

Zend PHP exposes stream_get_meta_data() and stream_set_blocking() for stream resource introspection and non-blocking I/O. This compiler registers related siblings (stream_get_contents, stream_set_timeout, buffer/chunk helpers) but does not register these two — user code and internal helpers that rely on them fail with Call to undefined function.

Verified 2026-06-05: Zend returns true for both function_exists() checks; VM returns false.

php-src reference

Repro

test/repro/stream_meta_blocking_missing.php:

<?php
$f = tmpfile();
var_dump(function_exists('stream_get_meta_data'));
var_dump(function_exists('stream_set_blocking'));
if (function_exists('stream_get_meta_data')) {
    var_dump(is_array(stream_get_meta_data($f)));
}
fclose($f);
docker info >/dev/null
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/stream_meta_blocking_missing.php
php bin/vm.php test/repro/stream_meta_blocking_missing.php
'
Runtime stream_get_meta_data stream_set_blocking
Zend PHP 8.2+ bool(true) + array meta bool(true)
vm.php today bool(false) bool(false)

Scope (PHP-in-PHP)

Path Work
ext/standard/stream_get_meta_data.php VM builtin returning wrapper/uri/mode/seekable/etc. keys
ext/standard/stream_set_blocking.php VM builtin toggling blocking on stream resources
lib/JIT/ Lower both for JIT/AOT when stream resource types are known
test/compliance/cases/stdlib/stream_get_meta_data.phpt Basic meta shape
test/compliance/cases/stdlib/stream_set_blocking.phpt Toggle + return value

Do not add large C tables in runtime/*.c. Reuse existing stream resource wrappers from ext/standard/stream_get_contents.php / VmFs.php where possible.

Done when

  • Repro prints bool(true) for both function_exists() on VM
  • stream_get_meta_data($fp) returns array with expected keys on a tmpfile() handle
  • stream_set_blocking($fp, false) returns true and affects subsequent reads where applicable
  • ./script/ci-fast.sh --filter stream_get_meta_data green

Related

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