Skip to content

Stdlib: stream_isatty() — TTY detection for stream resources missing (ext/standard/streamsfuncs.c) #6035

Description

@PurHur

Category

stdlib

Problem

Zend exposes stream_isatty($stream): bool to detect whether a stream resource is connected to a terminal. This compiler reports function_exists('stream_isatty') → false on bin/vm.php; scripts using CLI prompts, progress bars, or color libraries cannot branch on TTY availability.

php-src reference

Repro (failure today)

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "var_export(function_exists(\"stream_isatty\")); echo \"\\n\"; try { var_export(stream_isatty(STDIN)); } catch (Throwable \$e) { echo get_class(\$e); }"'

Observed (VM):

false
# undefined function on stream_isatty(STDIN)

Zend PHP expected: function_exists → true; stream_isatty(STDIN) → bool; non-resource → TypeError.

./script/docker-exec.sh -- bash -lc 'php -r "var_export(function_exists(\"stream_isatty\"));"'

Scope (this repo)

Layer Path Notes
Builtin ext/standard/stream_isatty.php
VM helper ext/standard/VmStream.php — isTty($resource): bool Use stream fd accessor
Register ext/standard/Module.php
JIT/AOT defer v1 Note VM-only in capability matrix
Tests test/compliance/cases/stdlib/stream_isatty.phpt stdin pipe vs tty when harness allows

PHP-in-PHP first: implement in ext/standard/; thin C ABI in runtime/ only if isatty(3) on native fd is unavoidable for AOT.

Done when

  • function_exists('stream_isatty') is true on VM
  • stream_isatty(STDIN) returns bool without fatal (value may differ pipe vs tty)
  • Non-resource argument throws TypeError matching Zend
  • ./script/ci-fast.sh --filter StreamIsatty green
  • docs/capabilities.md row added via script/capability-matrix.php

Verification

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

Links

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